Compiler Error C2156

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Compiler Error C2156.

pragma must be outside function

A pragma that must be specified at a global level (outside a function body) is within a function.

The following sample generates C2156:

// C2156.cpp  
#pragma optimize( "l", on )   // OK  
int main() {  
   #pragma optimize( "l", on )   // C2156  
}  

Show: