编译器错误 C2381

“函数”: 重定义; __declspec(noreturn) 不同

声明并定义函数,但定义使用了 noreturn__declspec 修饰符。 使用 noreturn 构成对函数的重定义;声明和定义需要就使用 noreturn 达成一致。

以下示例生成 C2381:

// C2381.cpp
// compile with: /c
void f1();
void __declspec(noreturn) f1() {}   // C2381
void __declspec(noreturn) f2() {}   // OK