【发布时间】:2023-03-07 18:03:01
【问题描述】:
我有包含这些声明的代码:
class IRealNetDll;
extern "C"__declspec(dllexport)
IRealNetDll * CreateRealInstance(int ilicence);
这可以在 Win7 上使用 Visual Studio 2012 正确构建。
但在 Windows 10 上的 VS 2015、2017 上,这一行:
extern "C"__declspec(dllexport)
结果:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C3690: expected a string literal, but found a user-defined string literal instead
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2146: syntax error: missing ';' before identifier 'IRealNetDll'
为什么会出现这个错误,为什么只在较新的编译器上出现,我该如何防止它?
【问题讨论】:
-
与您的问题无关,但以下划线开头并后跟大写字母的符号(例如
_IRealNetDll)在任何地方都保留。请参阅What are the rules about using an underscore in a C++ identifier? 了解更多信息 -
注意你的间距(或者更确切地说是事物之间的空间缺乏)。
-
@πάνταῥεῖ 错误非常与
extern "C"__declspec(dllexport)部分相关。错误消息的“用户定义的字符串文字”部分泄露了它。
标签: c++ visual-studio visual-c++ visual-studio-2012 windows-10