I started with what I thought was a reasonable statement:
#include "cstringt.h"
This gave me numerous errors, starting with:
C:\Program Files\Microsoft SDKs\Windows\v6.0\Include\ocidl.h(6238) : error C2872: 'IServiceProvider' : ambiguous symbol
C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\atlcomcli.h(370) : error C2872: 'DISPPARAMS' : ambiguous symbol
With a little research, I determined I was using the wrong include file. So I switched to:
#include "atlstr.h"
When I tried to do that, I received similar errors:
C:\Program Files\Microsoft SDKs\Windows\v6.0\Include\ocidl.h(6238) : error C2872: 'IServiceProvider' : ambiguous symbol
C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\atlcomcli.h(370) : error C2872: 'DISPPARAMS' : ambiguous symbol
Several other posts inquiring about the same errors received no answers.
The problem is caused because the Microsoft SDK (aka Platform SDK) and mscorlib both have definitions for these classes.
The solution is to take the #include file that caused the problem and make sure it is placed before any "using namespace" statement. In my case, that meant moving #include
Finally one quick solution after lot of googling. Thank you very much.
ReplyDeleteThanks!
ReplyDeleteThank you so much....it was a HUGE help!!
ReplyDeleteAwesome, but I still don't fully understand why it works.
ReplyDeleteHi Jim
ReplyDeleteI am facing similar problem but unable to fis it.
I am making a project and attaching a library code in it. Both projects are made with same project setting . In library project i have header file where i typedef CString but when i am compiling the main project I am getting following errors
C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxwin.h(3343): error C2872: 'CString' : ambiguous symbol
I tried changing the order of stdafx.h and other header files but no success.
Please help me out.
I'm not sure what you mean when you say "I typedef CString", but you can't typedef CString. You can only use the definitions that appear in the ATL header files because it's really a template underneath the covers. In any case, if CString were in your precompiled headers, there should be no need for you to typedef it.
ReplyDeleteThaks a lot!!!
ReplyDeleteProblem of ambigous symbol, while using native C++ from CLR C++ solved!
Thank you!!
ReplyDeleteThanks!!! It's 2015, and I still ran into the same problem!
ReplyDeleteThanks a lot!!!
ReplyDeleteThank you so much. appreciate it !
ReplyDeleteThanks a lot. Finally a solution that worked.
ReplyDelete