The #import feature includes a file named Comdef.h, which indirectly includes files that include Msxml.h. This is necessary because Comdef.h defines some common GUIDs and contains the following:
_COM_SMARTPTR_TYPEDEF(IXMLDocument, __uuidof(IXMLDocument));
_COM_SMARTPTR_TYPEDEF(IXMLElement, __uuidof(IXMLElement));
_COM_SMARTPTR_TYPEDEF(IXMLElementCollection, __uuidof(IXMLElementCollection));
_COM_SMARTPTR_TYPEDEF(IXMLElementNotificationSink, __uuidof(IXMLElementNotificationSink));
_COM_SMARTPTR_TYPEDEF(IXMLError, __uuidof(IXMLError));
Because these types are referenced, it is important for the Msxml.h file to be included. This causes redefinitions when #import'ing on the XML dynamic-link library (DLL). The redefinition errors occur when you use the no_namespace attribute for #import. Here is an example:
#import "c:\winnt\system32\msxml.dll" no_namespace
int main(int argc, char* argv[])
{
IXMLDOMDocumentPtr dom(__uuidof(DOMDocument));
The "ambiguous symbol" error can occur when you use a namespace with #import, and use the Msxml.h header file from the Platform Software Development Kit (SDK) or a newer preview XML SDK from the Web. Because the newer Msxml.h defines DOMDocument in the global namespace, and the #import defines it in another namespace, the symbol is ambiguous. Here is the code to reproduce the problem:
#import "c:\winnt\system32\msxml.dll"
using namespace MSXML;
int main(int argc, char* argv[])
{
IXMLDOMDocumentPtr dom(__uuidof(DOMDocument));