我正在尝试将一些 CLI 函数添加到现有的 C++ 库中。在其中一个包含类定义中
includedHeader.h:
class IncludedClass
{
SomeType generic;
SomeType specific;
}
此代码在 C++ 中编译,但 generic
成员名称现在被识别为关键字。有什么方法可以从部分代码中禁用新语法吗?
编辑:编译器错误是
error C2059: syntax error : 'generic'
error C2238: unexpected token(s) preceding ';'
都指带有“通用”的行。
最佳答案
如果你正在链接已编译的库,你可以这样做:
#define generic __identifier(generic)
#include <includedHeader.h>
#undef generic
关于visual-studio-2010 - 从 native C++ 迁移到 C++/CLI : new keywords conflict with old names,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9226866/