編譯器錯誤 C3724
以多執行緒模式使用事件需要在程式碼中加入 #include <windows.h>
如果您使用多線程搭配事件,則需要 windows.h 檔案。 若要修正此錯誤,請將 新增 #include <windows.h>
至定義事件來源和事件接收器的檔案頂端。
// C3724.cpp
// uncomment the following line to resolve
// #include <windows.h>
[event_source(native), threading(apartment)]
class CEventSrc {
public:
__event void event1(); // C3724
};
[event_receiver(native)]
class CEventRec {
public:
void handler1() {
}
void HookEvents(CEventSrc* pSrc) {
__hook(CEventSrc::event1, pSrc, CEventRec::handler1);
}
void UnhookEvents(CEventSrc* pSrc) {
__unhook(CEventSrc::event1, pSrc, CEventRec::handler1);
}
};
int main() {
}