【发布时间】:2012-06-16 07:54:46
【问题描述】:
使用 /clr 编译
array<Byte>^ byteArray = gcnew array<Byte>(25);
为什么会出现这些编译器错误?
error C2065: 'array' : undeclared identifier
error C2065: 'gcnew' : undeclared identifier
error C2275: 'System::Byte' : illegal use of this type as an expression
error C3192: syntax error : '^' is not a prefix operator (did you mean '*'?)
我在一个类中调用这个方法
using namespace System;
__gc class MyClass
这感觉就像我在这里遗漏了一些非常基本的东西。即使这样也会导致错误:
array<Byte>^ byteArray;
或
array<Byte> * byteArray;
谢谢!!
【问题讨论】:
-
确保您创建的项目是 C++/CLI 项目。
-
也许,您的某个标题包含
#pragma unmanaged某处 -
如果该类声明编译,那么您正在使用 /clr:oldsyntax。或者是VS2005之前的真正旧版本的VS。两者都不会解析 array
标签: arrays c++-cli clr managed managed-c++