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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. can't use exported func in a namespace

can't use exported func in a namespace

Scheduled Pinned Locked Moved C / C++ / MFC
help
5 Posts 3 Posters 1 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.
  • H Offline
    H Offline
    happycpp
    wrote on last edited by
    #1

    hello everyone... i have this thing that drives me crazy..this thing is: i have a dll that exports a function "Func"...and i'm making (in another project) a namespace that has this function...the problem is that i can't use this function in a namespace but i can use it easily if it's not in a namespace...the error reported is LNK2019... what should i do..

    D J 2 Replies Last reply
    0
    • H happycpp

      hello everyone... i have this thing that drives me crazy..this thing is: i have a dll that exports a function "Func"...and i'm making (in another project) a namespace that has this function...the problem is that i can't use this function in a namespace but i can use it easily if it's not in a namespace...the error reported is LNK2019... what should i do..

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      saeedmalas wrote: ...the error reported is LNK2019... Is this a .Net-related error?


      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      1 Reply Last reply
      0
      • H happycpp

        hello everyone... i have this thing that drives me crazy..this thing is: i have a dll that exports a function "Func"...and i'm making (in another project) a namespace that has this function...the problem is that i can't use this function in a namespace but i can use it easily if it's not in a namespace...the error reported is LNK2019... what should i do..

        J Offline
        J Offline
        Joaquin M Lopez Munoz
        wrote on last edited by
        #3

        Do you mean the function is exported outside any namespace and then tried to import inside a namespace? If so, I guess you're out of luck, namespace location has to coincide. Think of the namespace(s) a function is located into as part of its "name". A workaround could be the following:

        // import code

        declspec(dllimport) void foo();

        namespace A
        {
        using foo;
        }

        Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Want a Boost forum in Code Project? Vote here[^]!

        H 2 Replies Last reply
        0
        • J Joaquin M Lopez Munoz

          Do you mean the function is exported outside any namespace and then tried to import inside a namespace? If so, I guess you're out of luck, namespace location has to coincide. Think of the namespace(s) a function is located into as part of its "name". A workaround could be the following:

          // import code

          declspec(dllimport) void foo();

          namespace A
          {
          using foo;
          }

          Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Want a Boost forum in Code Project? Vote here[^]!

          H Offline
          H Offline
          happycpp
          wrote on last edited by
          #4

          i'm using the .net ide but i'm not using any new .net managedcode just regular cpp code... the functions in the dll are exported using a .def file... so they have their original names...how can i make a namespace in another project to encapsulate these functions... this is the same thing that microsoft made with GDI+...

          1 Reply Last reply
          0
          • J Joaquin M Lopez Munoz

            Do you mean the function is exported outside any namespace and then tried to import inside a namespace? If so, I guess you're out of luck, namespace location has to coincide. Think of the namespace(s) a function is located into as part of its "name". A workaround could be the following:

            // import code

            declspec(dllimport) void foo();

            namespace A
            {
            using foo;
            }

            Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Want a Boost forum in Code Project? Vote here[^]!

            H Offline
            H Offline
            happycpp
            wrote on last edited by
            #5

            i want to do the same thing as Gdi+ dll...

            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