Redigera

Dela via


Compiler Warning (level 3) C4768

__declspec attributes before linkage specification are ignored

The compiler warns if __declspec(...) is applied before the extern "C" linkage specification. Previously, the compiler would ignore the attribute, which could have runtime implications.

Remarks

This warning is new in Visual Studio 2017 version 15.3, which left it off by default. It's enabled by default as a level 3 warning starting in Visual Studio 2017 version 15.5. For information on how to disable warnings by compiler version, see Compiler warnings by compiler version.

Example

The following code produces warning C4768:

__declspec(noinline) extern "C" HRESULT __stdcall // C4768: __declspec attributes before linkage specification are ignored

To fix the warning, put extern "C" first:

extern "C" __declspec(noinline) HRESULT __stdcall