Compiler Error C2157

 

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 C2157.

function' : must be declared before use in pragma list

The function name is not declared before being referenced in the list of functions for an alloc_text pragma.

The following sample generates C2157:

// C2157.cpp  
// compile with: /c  
#pragma alloc_text( "func", func)   // C2157  
  
// OK  
extern "C" void func();  
#pragma alloc_text( "func", func)  

Show: