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..3710ca2abe 100644 --- a/docs/error-messages/compiler-errors-2/compiler-error-c3187.md +++ b/docs/error-messages/compiler-errors-2/compiler-error-c3187.md @@ -1,15 +1,33 @@ --- -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 -> '`__func__`' : is only available within the body of a function +> '`__func__`': is only available within the body of a function + +## Remarks + +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 +``` -The predefined macro is not available outside the body of a function. +## See also -To correct this error, move the macro inside the body of a function. +[C2457](../compiler-errors-1/compiler-error-c2457.md) 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..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"] @@ -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*' |