我有一个.NET库,我正在编写一个C ++ / CLI包装器,以便将公共成员公开给本地世界。其中一个要求是对字符串使用CComBSTR并完全避免使用std名称空间。
为此,我将atlbase.h头文件包含在内以使用CComBSTR。就包装纸或其单元测试而言,一切都运行良好。但是当我尝试在现有项目中使用包装器头文件和库时,我注意到大量的编译错误都来自于不直接属于我正在编译的项目的文件。我在下面发布了一些内容:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(560): error C2039: 'vt' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(561): error C2039: 'vt' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(932): error C2039: 'vt' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(933): error C2039: 'bstrVal' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(935): error C2039: 'bstrVal' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1798): error C2039: 'cVal' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1798): error C2065: 'cVal' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1808): error C2039: 'bVal' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1808): error C2065: 'bVal' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1818): error C2039: 'pcVal' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1818): error C2065: 'pcVal' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1828): error C2039: 'pbVal' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1828): error C2065: 'pbVal' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1838): error C2039: 'iVal' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1838): error C2065: 'iVal' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1848): error C2039: 'piVal' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1848): error C2065: 'piVal' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1858): error C2039: 'uiVal' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1858): error C2065: 'uiVal' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1869): error C2039: 'puiVal' : is not a member of 'tagVARIANT'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\oaidl.h(455) : see declaration of 'tagVARIANT'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1869): error C2065: 'puiVal' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\atlcomcli.h(1880): error C2039: 'intVal' : is not a member of 'tagVARIANT'
我尝试了一些像https://answers.unrealengine.com/questions/56125/problems-with-including-atlbase-in-ue4-onlyproblem.html中那样的建议,但它没有帮助。我宁愿不必对应用程序项目进行任何更改,而是在包装器项目本身中执行某些操作来解决这些编译错误。