C2059 Error Using extern "C" in .C Source Files

C2059 Error Using extern "C" in .C Source Files


The information to this article applies to:
The Microsoft C/C++ Compiler included with: - Microsoft Visual C++, 32-bit Edition, versions 2.0, 2.1, 2.2, 4.0,

     4.1, 5.0

SUMMARY
Use of "extern "C"" in source files that have a .C extension causes error C2059, and results in this error message:

   error C2059:syntax error:'string'

CAUSE
In the C language, the string-literal "C" is not recognized. It is used in C++ to prevent name decoration.

RESOLUTION
Remove the string-literal "C" in extern declarations, or use the following in the function declaration:


   #ifdef __cplusplus
      extern "C"
   #endif 

你可能感兴趣的:(C++/C,基础编程)