請看看下面的頭文件混合型,不支持
#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