You may be using namespace ado20
somewhere in the code. To tell the compiler that you want to use global DataTypeEnum
type (which you probably do since that is what CNCQuickADO::ConvertADOType()
expects judging from error messages), declare your variable(s) with fully-qualified type ::DataTypeEnum
.
Ambiguous symbol - cannot convert from ado::DataTypeEnum to DataTypeEnum
-
13-10-2022 - |
Question
Trying to compile a C++ project containing an SQL library and getting these errors:
error C2664: 'CNCQuickADO::ConvertADOType' : cannot convert parameter 1 from 'ado20::DataTypeEnum' to 'DataTypeEnum'
Conversion to enumeration type requires an explicit cast
error C2664: 'CNCQuickADO::ConvertADOType' : cannot convert parameter 1 from 'ado20::DataTypeEnum' to 'DataTypeEnum'
Conversion to enumeration type requires an explicit cast
error C2872: 'DataTypeEnum' : ambiguous symbol
could be 'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\dbdaoint.h : DataTypeEnum
or 'c:\amc\source\amthrottling\release\msado15.tlh : ado20::DataTypeEnum
I use the SQL library in several other projects with no issue like this. So I am guessing it must be something to do with where I'm including the library?
Can anyone help? Thanks!
Solution
OTHER TIPS
The namespace is very important design in c++.
In ado20::DataTypeEnum
, ado20
is the namespace, DataTypeEnum
is the name in this namespace.
ado20::DataTypeEnum
and othernamespace::DataTypeEnum
are different variables which are distinguished from the namespace.
C++ realizes this by modify the variable name. For example, ado20::DataTypeEnum
can be processed as _ado20_DataTypeEnum
, while othernamespace::DataTypeEnum
be _othernamespace_DataTypeEnum
.
Another example of using the namespace:
using namespace ado20; // declare the namespace
// other code ...
DateTypeEnum yourvariable; // now you can directly use variable in the namespace