请看看下面的头文件混合型,不支持
#pragma once
using namespace UsbLibrary;
ref class MissileLauncher
{
public:
MissileLauncher(void);
private:
//Bytes used in command
unsigned char UP[10];
unsigned char RIGHT[10];
unsigned char LEFT[10];
unsigned char DOWN[10];
unsigned char FIRE[10];
unsigned char STOP[10];
unsigned char LED_OFF[9];
unsigned char LED_ON[9];
UsbHidPort USB;
};
我使用的是Visual C++项目(C++/CLI?)在Visual Studio专业2010年当我运行这段代码,我得到很多错误
Error 1 error C4368: cannot define 'UP' as a member of managed 'MissileLauncher': mixed types are not supported
Error 2 error C4368: cannot define 'RIGHT' as a member of managed 'MissileLauncher': mixed types are not supported
Error 3 error C4368: cannot define 'LEFT' as a member of managed 'MissileLauncher': mixed types are not supported
Error 4 error C4368: cannot define 'DOWN' as a member of managed 'MissileLauncher': mixed types are not supported
Error 5 error C4368: cannot define 'FIRE' as a member of managed 'MissileLauncher': mixed types are not supported
Error 6 error C4368: cannot define 'STOP' as a member of managed 'MissileLauncher': mixed types are not supported
Error 7 error C4368: cannot define 'LED_OFF' as a member of managed 'MissileLauncher': mixed types are not supported
Error 8 error C4368: cannot define 'LED_ON' as a member of managed 'MissileLauncher': mixed types are not supported
在这里,命名空间USBLibrary
来自C#的dll文件。该UsbHidPort;
是从C#DLL
那么,为什么我收到此错误的对象?有任何想法吗?
我建议阅读[本文档](http://blogs.msdn.com/b/branbray/archive/2005 /07/20/441099.aspx),其中讨论了原生类型,管理类型,以及何时/如何/如果一个可以容纳其他的,在长度这么做。这是一个有点过时,但它的症结会告诉你,你有,为什么你有它的问题,事情可以做了。 – WhozCraig 2013-05-10 20:27:10