From 013292ca980791adf2d4ba55b4e4889d4bdd4bcf Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Fri, 15 Aug 2025 16:23:20 +0800 Subject: [PATCH 1/6] Add "Remarks" heading in C3187 error reference --- docs/error-messages/compiler-errors-2/compiler-error-c3187.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md index 4ef3efeedb..67cebe86c1 100644 --- a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md +++ b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md @@ -10,6 +10,8 @@ ms.assetid: 9d2ebf55-1a6a-4087-bf5b-5274baae6351 > '`__func__`' : is only available within the body of a function +## Remarks + The predefined macro is not available outside the body of a function. To correct this error, move the macro inside the body of a function. From 59adf3ebac46a3349c44a08d456ecfc36a53608e Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Fri, 15 Aug 2025 16:27:18 +0800 Subject: [PATCH 2/6] Add link and tweak remarks in C3187 error reference --- docs/error-messages/compiler-errors-2/compiler-error-c3187.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md index 67cebe86c1..8195456820 100644 --- a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md +++ b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md @@ -12,6 +12,6 @@ ms.assetid: 9d2ebf55-1a6a-4087-bf5b-5274baae6351 ## Remarks -The predefined macro is not available outside the body of a function. +The predefined identifier [`__func__`](../../cpp/func.md) is not available outside the body of a function. -To correct this error, move the macro inside the body of a function. +To correct this error, move the identifier inside the body of a function. From 6f6a2b240d9c8e4966fade4c9758a6f92ea06a39 Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Fri, 15 Aug 2025 16:42:35 +0800 Subject: [PATCH 3/6] Add example in C3187 error reference --- .../compiler-errors-2/compiler-error-c3187.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md index 8195456820..e82957b16e 100644 --- a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md +++ b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md @@ -15,3 +15,16 @@ ms.assetid: 9d2ebf55-1a6a-4087-bf5b-5274baae6351 The predefined identifier [`__func__`](../../cpp/func.md) is not available outside the body of a function. To correct this error, move the identifier inside the body of a function. + +## Example + +The following example generates C3187: + +```cpp +// C3187.cpp +// compile with: /c + +auto global = __func__; // C3187, usage in global scope + +void func(const char* f = __func__); // C3187, usage in parameter list +``` From 6ffde87dfebbc768e32977c90ac877b0663f0e16 Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Fri, 15 Aug 2025 16:50:32 +0800 Subject: [PATCH 4/6] Update error message for C3187 --- docs/error-messages/compiler-errors-2/compiler-error-c3187.md | 2 +- .../compiler-errors-2/compiler-errors-c3100-through-c3199.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md index e82957b16e..423bc277df 100644 --- a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md +++ b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md @@ -8,7 +8,7 @@ ms.assetid: 9d2ebf55-1a6a-4087-bf5b-5274baae6351 --- # Compiler Error C3187 -> '`__func__`' : is only available within the body of a function +> '`__func__`': is only available within the body of a function ## Remarks diff --git a/docs/error-messages/compiler-errors-2/compiler-errors-c3100-through-c3199.md b/docs/error-messages/compiler-errors-2/compiler-errors-c3100-through-c3199.md index 338e4eceb9..d9fb371919 100644 --- a/docs/error-messages/compiler-errors-2/compiler-errors-c3100-through-c3199.md +++ b/docs/error-messages/compiler-errors-2/compiler-errors-c3100-through-c3199.md @@ -102,7 +102,7 @@ The articles in this section of the documentation explain a subset of the error | Compiler error C3184 | Obsolete. | | [Compiler error C3185](compiler-error-c3185.md) | 'typeid': used on managed/WinRT type '*type*', use '*operator*' instead | | Compiler error C3186 | Obsolete. | -| [Compiler error C3187](compiler-error-c3187.md) | '*identifier*': is only available within the body of a function | +| [Compiler error C3187](compiler-error-c3187.md) | '`__func__`': is only available within the body of a function | | Compiler error C3188 | Obsolete. | | [Compiler error C3189](compiler-error-c3189.md) | 'typeid<*declarator*>': this syntax is no longer supported, use::typeid instead (Obsolete in Visual Studio 2022.) | | [Compiler error C3190](compiler-error-c3190.md) | '*declarator*' with the provided template arguments is not the explicit instantiation of any member function of '*type*' | From ac6165812a63146a1071bd3f23e272458a22d8bd Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Fri, 15 Aug 2025 16:52:39 +0800 Subject: [PATCH 5/6] Update metadata in 2 error reference topics --- .../error-messages/compiler-errors-2/compiler-error-c3187.md | 5 ++--- .../compiler-errors-2/compiler-errors-c3100-through-c3199.md | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md index 423bc277df..f4f244b6d9 100644 --- a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md +++ b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md @@ -1,10 +1,9 @@ --- -description: "Learn more about: Compiler Error C3187" title: "Compiler Error C3187" -ms.date: "11/04/2016" +description: "Learn more about: Compiler Error C3187" +ms.date: 08/15/2025 f1_keywords: ["C3187"] helpviewer_keywords: ["C3187"] -ms.assetid: 9d2ebf55-1a6a-4087-bf5b-5274baae6351 --- # Compiler Error C3187 diff --git a/docs/error-messages/compiler-errors-2/compiler-errors-c3100-through-c3199.md b/docs/error-messages/compiler-errors-2/compiler-errors-c3100-through-c3199.md index d9fb371919..92e4a1b994 100644 --- a/docs/error-messages/compiler-errors-2/compiler-errors-c3100-through-c3199.md +++ b/docs/error-messages/compiler-errors-2/compiler-errors-c3100-through-c3199.md @@ -1,6 +1,6 @@ --- -description: "Learn more about: Compiler errors C3100 Through C3199" title: "Compiler errors C3100 Through C3199" +description: "Learn more about: Compiler errors C3100 Through C3199" ms.date: 06/01/2022 f1_keywords: ["C3102", "C3105", "C3107", "C3108", "C3109", "C3111", "C3112", "C3119", "C3122", "C3123", "C3124", "C3125", "C3127", "C3128", "C3129", "C3143", "C3144", "C3146", "C3147", "C3148", "C3151", "C3158", "C3164", "C3165", "C3169", "C3177", "C3178", "C3184", "C3186", "C3188", "C3191", "C3193"] helpviewer_keywords: ["C3102", "C3105", "C3107", "C3108", "C3109", "C3111", "C3112", "C3119", "C3122", "C3123", "C3124", "C3125", "C3127", "C3128", "C3129", "C3143", "C3144", "C3146", "C3147", "C3148", "C3151", "C3158", "C3164", "C3165", "C3169", "C3177", "C3178", "C3184", "C3186", "C3188", "C3191", "C3193"] From b8cdb92469c34f627b1d06021876c92c8cb9e24d Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Fri, 15 Aug 2025 16:58:16 +0800 Subject: [PATCH 6/6] Add C2457 "See also" link in C3187 error reference --- docs/error-messages/compiler-errors-2/compiler-error-c3187.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md index f4f244b6d9..3710ca2abe 100644 --- a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md +++ b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md @@ -27,3 +27,7 @@ auto global = __func__; // C3187, usage in global scope void func(const char* f = __func__); // C3187, usage in parameter list ``` + +## See also + +[C2457](../compiler-errors-1/compiler-error-c2457.md)