c++ - 在 Visual C++ 上使用 msxml6.h 时出错

标签 c++ visual-studio-2010 visual-c++ msxml6

在 visual studio 2010 中,如果我启动一个控制台项目并使用#include,它工作正常,但如果我启动一个 win32 项目并使用#include,它会在编译期间返回许多错误。

为什么?

Error    1   error C2146: syntax error : missing ';' before identifier 'IXMLDOMImplementation'   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    49  1   provamsxml6
Error   2   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    49  1   provamsxml6
Error   3   error C2146: syntax error : missing ';' before identifier 'IXMLDOMImplementation'   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    49  1   provamsxml6
Error   4   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    49  1   provamsxml6
Error   5   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    49  1   provamsxml6
Error   6   error C2086: 'int IXMLDOMImplementation' : redefinition c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    49  1   provamsxml6
Error   7   error C2146: syntax error : missing ';' before identifier 'IXMLDOMNode' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    55  1   provamsxml6
Warning 8   warning C4091: '' : ignored on left of 'interface' when no variable is declared c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    55  1   provamsxml6
Error   9   error C2146: syntax error : missing ';' before identifier 'IXMLDOMDocumentFragment' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    61  1   provamsxml6
Warning 10  warning C4091: '' : ignored on left of 'interface' when no variable is declared c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    61  1   provamsxml6
Error   11  error C2146: syntax error : missing ';' before identifier 'IXMLDOMDocument' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    67  1   provamsxml6
Warning 12  warning C4091: '' : ignored on left of 'interface' when no variable is declared c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    67  1   provamsxml6
Error   13  error C2146: syntax error : missing ';' before identifier 'IXMLDOMDocument2'    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    73  1   provamsxml6
Warning 14  warning C4091: '' : ignored on left of 'interface' when no variable is declared c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    73  1   provamsxml6
Error   15  error C2146: syntax error : missing ';' before identifier 'IXMLDOMDocument3'    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    79  1   provamsxml6
Warning 16  warning C4091: '' : ignored on left of 'interface' when no variable is declared c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    79  1   provamsxml6
Error   17  error C2146: syntax error : missing ';' before identifier 'IXMLDOMNodeList' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    85  1   provamsxml6
Warning 18  warning C4091: '' : ignored on left of 'interface' when no variable is declared c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    85  1   provamsxml6
Error   19  error C2146: syntax error : missing ';' before identifier 'IXMLDOMNamedNodeMap' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    91  1   provamsxml6
Warning 20  warning C4091: '' : ignored on left of 'interface' when no variable is declared c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    91  1   provamsxml6
Error   21  error C2146: syntax error : missing ';' before identifier 'IXMLDOMCharacterData'    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    97  1   provamsxml6
Warning 22  warning C4091: '' : ignored on left of 'interface' when no variable is declared c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    97  1   provamsxml6
Error   23  error C2146: syntax error : missing ';' before identifier 'IXMLDOMAttribute'    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    103 1   provamsxml6
Warning 24  warning C4091: '' : ignored on left of 'interface' when no variable is declared c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    103 1   provamsxml6
Error   25  error C2146: syntax error : missing ';' before identifier 'IXMLDOMElement'  c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    109 1   provamsxml6
Warning 26  warning C4091: '' : ignored on left of 'interface' when no variable is declared c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    109 1   provamsxml6
Error   27  error C2146: syntax error : missing ';' before identifier 'IXMLDOMText' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    115 1   provamsxml6
Warning 28  warning C4091: '' : ignored on left of 'interface' when no variable is declared c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    115 1   provamsxml6
Error   29  error C2146: syntax error : missing ';' before identifier 'IXMLDOMComment'  c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    121 1   provamsxml6
Warning 30  warning C4091: '' : ignored on left of 'interface' when no variable is declared c:\program files (x86)\microsoft sdks\windows\v7.0a\include\msxml6.h    121 1   provamsxml6

最佳答案

缺少的是#include <ole2.h>或其中的一部分。
WIN32_LEAN_AND_MEAN已定义 Ole2 是从 Windows.h 中删除的标题之一.
如果 INC_OLE2 可以加回 Ole2已定义。

如果你提供了一个标题并且不确定用户可能定义什么那么你可以为了安全起见

#if !defined(INC_OLE2) && defined(WIN32_LEAN_AND_MEAN)
#include <ole2.h>
#endif
#include <msxml2.h>

关于c++ - 在 Visual C++ 上使用 msxml6.h 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10934270/

相关文章:

c++ - std::string的大小是否总是打印字符的数量?

c++ - 从 VS19 在 Linux 远程计算机上生成 CMake 不起作用

c++ - 如何在引用上设置数据断点

visual-studio-2010 - 将 PostgreSQL 安装程序添加到我自己的应用程序安装程序

c++ - 在 Windows 中使用 Apache Thrift

c++ - 如何在 C++ 或 MFc 中对 CTypedPtrList 进行排序?

c++ - 尝试访问 it 属性时前向声明 'const class LHContactInfo' 错误

c++ - 如何平衡两个数组之间的差异最小化?

c# - 您知道有可用的 F# 和 C# 互操作示例吗?

c# - DBContext多线程