__identifier (C++/CLI)

启用使用 Visual C++ 关键字用作标识符。

所有平台

语法

__identifier(Visual_C++_keyword)

备注

使用不包含关键字的标识符的 __identifier 关键字的用法是允许,但强烈不建议这种样式。

Windows 运行时

要求

编译器选项:/ZW

示例

示例

在下面的示例中,名为 template 的类创建并分发 C# 作为 DLL。 在使用 template 类的 Visual C++ 程序,__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:oldSyntax 编译器选项。

要求

编译器选项:/clr

示例

示例

在下面的示例中,名为 template 的类创建并分发 C# 作为 DLL。 在使用 template 类的 Visual C++ 程序,__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();
}

请参见

概念

适用于运行时平台的组件扩展

适用于运行时平台的组件扩展