开发者

How to make an "ambiguous symbol" unique with VS 2008

I have some trouble with #define statements in my C++ code, however I'm not familiar how to handle this in VC++:

>filetaint.cpp
1>.\filetaint.cpp(272) : error C2872: 'UINT32' : ambiguous symbol
1>        could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\\include\basetsd.h(82) : unsigned int WIND::UINT32'
1>        or       '..\..\include\gen\types_foundation.TLH(80) : LEVEL_BASE::UINT32'
1>.\filetaint.cpp(275) : error C2872: 'UINT32' : ambiguous symbol
1>        could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\\include\basetsd.h(82) : unsigned 
[...]

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

So the issue is that, that the compiler doesn't know whether to use the definition from my Windows SDK "basetsh.h or from types_foundation.h. I want it to use the latter. Is there any construct in C++ namespaces to tell the compiler what to chose? I want to avoid to patch the SDK or the library itself.

#include "filetaint.h"
#include "dift.h"

using namespace WIND;

The types_foundation.TLH contains the right statement. It is already in the VC++ paths in VS 2008. I'm a little confused here... but I guess I have to find a way to tell my 开发者_Python百科compiler to ignore the SDK for the time being ;).


I want it to use the latter.

Then qualify your usage with the namespace name: LEVEL_BASE::UINT32.

Alternatively, remove the using directives from your code and qualify all of the names that you use from the libraries. It's a good idea to avoid using directives in most cases: they are far more trouble than they are worth.


Yes.

Write the name fully-qualified with its namespace, instead of relying on the compiler to magically pick the right one for you:

LEVEL_BASE::UINT32

Am I missing something here?


Qualify it explicitly with namespace name, wherever you are using it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜