Having trouble with a namespace and class type collision in C++/C# project
-
I have a C++ app that includes a 3rd party library that has a type called 'System'. This class exists in a namespace, let's call it XYZ::System. Then I am compiling my C++ app with /clr and somehow when VC8 includes xlocale (which in turn uses a macro defined in yvals.h) that calls a method in .NET (System.bla.bla) there is an ambiguity. How can I resolve this easily?
-
I have a C++ app that includes a 3rd party library that has a type called 'System'. This class exists in a namespace, let's call it XYZ::System. Then I am compiling my C++ app with /clr and somehow when VC8 includes xlocale (which in turn uses a macro defined in yvals.h) that calls a method in .NET (System.bla.bla) there is an ambiguity. How can I resolve this easily?
use ::System and XYZ::System instead of just use System My blogs: http://blog.joycode.com/jiangsheng http://blog.csdn.net/jiangsheng http://bloglines.com/public/jiangsheng Command what is yours Conquer what is not ---Kane
-
use ::System and XYZ::System instead of just use System My blogs: http://blog.joycode.com/jiangsheng http://blog.csdn.net/jiangsheng http://bloglines.com/public/jiangsheng Command what is yours Conquer what is not ---Kane
Well that might work for my own source code but VC8 includes VC headers that call managed code and make calls to System:: namespace classes. This means I would have to modify all of these Microsoft headers by hand for this to work, which would be impossible to do without causing all sorts of other headaches. Is there not some way to rename a known .NET namespace to another name? Like rename ::System to ::DotNetSystem ?
-
Well that might work for my own source code but VC8 includes VC headers that call managed code and make calls to System:: namespace classes. This means I would have to modify all of these Microsoft headers by hand for this to work, which would be impossible to do without causing all sorts of other headaches. Is there not some way to rename a known .NET namespace to another name? Like rename ::System to ::DotNetSystem ?
try surrounding your include line with #define and #undef to avoid name collision.. My blogs: http://blog.joycode.com/jiangsheng http://blog.csdn.net/jiangsheng http://bloglines.com/public/jiangsheng Command what is yours Conquer what is not ---Kane
-
try surrounding your include line with #define and #undef to avoid name collision.. My blogs: http://blog.joycode.com/jiangsheng http://blog.csdn.net/jiangsheng http://bloglines.com/public/jiangsheng Command what is yours Conquer what is not ---Kane
If I do something like the following:
#define #include "XYZ.h" using namespace XYZ; #undef
I get the following error: error C2007: #define syntax I get that error withour without the using namespace statement as well. Is that what you meant or was it something else?