__identifier (C++/CLI)
允许使用 C++ 关键字作为标识符。
所有平台
语法
__identifier(C++_keyword)
备注
允许对不是关键字的标识符使用 _identifier 关键字,但强烈建议不要这样做。
Windows 运行时
要求
编译器选项:/ZW
示例
示例
在以下示例中,名为 template
的类在 C# 中创建并作为 DLL 分发。 在使用 template
类的 C++/CLI 程序中,__identifier
关键字隐瞒了 template
是标准 C++ 关键字的事实。
// identifier_template.cs
// compile with: /target:library
public class template {
public void Run() { }
}
// keyword__identifier.cpp
// compile with: /ZW
#using <identifier_template.dll>
int main() {
__identifier(template)^ pTemplate = ref new __identifier(template)();
pTemplate->Run();
}
公共语言运行时
注解
_identifier 关键字对 /clr
编译器选项有效。
要求
编译器选项:/clr
示例
在以下示例中,名为 template
的类在 C# 中创建并作为 DLL 分发。 在使用 template
类的 C++/CLI 程序中,__identifier
关键字隐瞒了 template
是标准 C++ 关键字的事实。
// identifier_template.cs
// compile with: /target:library
public class template {
public void Run() { }
}
// keyword__identifier.cpp
// compile with: /clr
#using <identifier_template.dll>
int main() {
__identifier(template) ^pTemplate = gcnew __identifier(template)();
pTemplate->Run();
}
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈