__declspec(关键字)不能与 /clr:pure 或 /clr:safe 一起使用
备注
/clr:pure 和 /clr:safe 编译器选项在 Visual Studio 2015 中已弃用,并且在 Visual Studio 2017 中不受支持。
使用 __declspec 修饰符表示每个进程的状态。
/clr:pure 表示每个 appdomain 的状态。 因此,使用关键字 修饰符声明变量并使用 __declspec 进行编译是不允许的/clr:pure。
示例
以下示例生成 C3389:
// C3389.cpp
// compile with: /clr:pure /c
__declspec(dllexport) int g2 = 0; // C3389