Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Having trouble with a namespace and class type collision in C++/C# project

Having trouble with a namespace and class type collision in C++/C# project

Scheduled Pinned Locked Moved Managed C++/CLI
csharpquestionc++dotnet
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dxben
    wrote on last edited by
    #1

    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?

    S 1 Reply Last reply
    0
    • D dxben

      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?

      S Offline
      S Offline
      Sheng Jiang
      wrote on last edited by
      #2

      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

      D 1 Reply Last reply
      0
      • S Sheng Jiang

        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

        D Offline
        D Offline
        dxben
        wrote on last edited by
        #3

        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 ?

        S 1 Reply Last reply
        0
        • D dxben

          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 ?

          S Offline
          S Offline
          Sheng Jiang
          wrote on last edited by
          #4

          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

          D 1 Reply Last reply
          0
          • S Sheng Jiang

            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

            D Offline
            D Offline
            dxben
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups