编译器错误 C2434
“symbol”:使用 __declspec(process) 声明的符号不能以 /clr:pure 模式动态初始化
注解
“/clr:pure”和“/clr:safe”编译器选项在 Visual Studio 2015 中已弃用,并且在 Visual Studio 2017 中不受支持。
无法在 /clr:pure 下动态初始化每进程变量。 有关详细信息,请参阅 /clr(公共语言运行时编译)和 process。
示例
以下示例生成 C2434。 若要解决此问题,请使用常量来初始化 process
变量。
// C2434.cpp
// compile with: /clr:pure /c
int f() { return 0; }
__declspec(process) int i = f(); // C2434
__declspec(process) int i2 = 0; // OK
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈