'IDataObject': ambiguous symbol的解决方法

今天在使用managed C++捕获系统消息时,编译出现了以下问题:

'IDataObject': ambiguous symbol
'IServiceProvider': redefinition; different basic types
'IServiceProvider': ambiguous symbol

google一番后,发现还是自己的问题,在.h文件里使用了using namespace System,而这个头文件在.cpp文件里是第一个引用的头文件。

这就导致了在.cpp文件里出现了using namespace 在#include "***.h"的情况,导致上面问题的发生。到底是自己业务不熟造成的,:(

解决方法就是确保所有的using namespace xxxx在 #include "xxxx.h"之后。

另附hook系统消息使用的几个头文件,备忘在此。

#include "windows.h"
#include "Wtsapi32.h"
#include <initguid.h>
#include "Usbiodef.h"
#include "Wiaintfc.h"
#include <Dbt.h>

https://social.msdn.microsoft.com/Forums/vstudio/en-US/92c473d6-c963-44fa-9150-6c6af502112b/ambiguous-symbol?forum=vcgeneral

原文地址:https://www.cnblogs.com/cg88/p/9150617.html