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. C / C++ / MFC
  4. extern "C" in VisualStudio

extern "C" in VisualStudio

Scheduled Pinned Locked Moved C / C++ / MFC
questionhtmldebugging
9 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.
  • M Offline
    M Offline
    Marcello
    wrote on last edited by
    #1

    Hello, I am using the tecnique http://www.lambdasoft.dk/comet/doc/cometautoexp.html in order to provides custom formatting for variables in the VisualStudio debugger. I can tell that it works very well. What puzzles me is this. In the code I export the function from the DLL in this way: extern "C" { __declspec(dllexport) HRESULT WINAPI VCF_DateTimeEvaluate( DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings, char *pResult, size_t maxlen, DWORD reserved ); } But then: dumpbin /exports AutoExp.dll shows _VCF_DateTimeEvaluate@28 instead than simply VCF_DateTimeEvaluate both by compiling with vc6 and vc70. Other people swear that I should simply get VCF_DateTimeEvaluate as long as I use: extern "C" { ... } Please note that extern "C" does something anyway, because without it I would get the mangled name: ?VCF_DateTimeEvaluate@@YGJKPAUtagDEBUGHELPER@@HHPADIK@Z If you have the patience to answer to another related question, here it is ! If I do use a definition file, it works with vc6 by just including it in the project, as I get: VCF_DateTimeEvaluate But with vc70 it doesn't work. Why ? What should I do different ?

    D 1 Reply Last reply
    0
    • M Marcello

      Hello, I am using the tecnique http://www.lambdasoft.dk/comet/doc/cometautoexp.html in order to provides custom formatting for variables in the VisualStudio debugger. I can tell that it works very well. What puzzles me is this. In the code I export the function from the DLL in this way: extern "C" { __declspec(dllexport) HRESULT WINAPI VCF_DateTimeEvaluate( DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings, char *pResult, size_t maxlen, DWORD reserved ); } But then: dumpbin /exports AutoExp.dll shows _VCF_DateTimeEvaluate@28 instead than simply VCF_DateTimeEvaluate both by compiling with vc6 and vc70. Other people swear that I should simply get VCF_DateTimeEvaluate as long as I use: extern "C" { ... } Please note that extern "C" does something anyway, because without it I would get the mangled name: ?VCF_DateTimeEvaluate@@YGJKPAUtagDEBUGHELPER@@HHPADIK@Z If you have the patience to answer to another related question, here it is ! If I do use a definition file, it works with vc6 by just including it in the project, as I get: VCF_DateTimeEvaluate But with vc70 it doesn't work. Why ? What should I do different ?

      D Offline
      D Offline
      darkbyte
      wrote on last edited by
      #2

      Did you add an entry to your .def file ? DLLEXPORT VCF_DateTimeEvaluate PRIVATE Its probably auto-generating something if you dont have it in the def file.

      M 1 Reply Last reply
      0
      • D darkbyte

        Did you add an entry to your .def file ? DLLEXPORT VCF_DateTimeEvaluate PRIVATE Its probably auto-generating something if you dont have it in the def file.

        M Offline
        M Offline
        Marcello
        wrote on last edited by
        #3

        Thank you very much. At least an answer ! But it doesn't work :( This is my definition file for vc70: AutoExp.vcproj, AutoExp.cpp and AutoExp.def are all in the same directory AutoExp.vcproj has AutoExp.cpp and AutoExp.def in itself. Is there, maybe, some options in the project that creates problems ? Cheers, Marcello

        D 2 Replies Last reply
        0
        • M Marcello

          Thank you very much. At least an answer ! But it doesn't work :( This is my definition file for vc70: AutoExp.vcproj, AutoExp.cpp and AutoExp.def are all in the same directory AutoExp.vcproj has AutoExp.cpp and AutoExp.def in itself. Is there, maybe, some options in the project that creates problems ? Cheers, Marcello

          D Offline
          D Offline
          darkbyte
          wrote on last edited by
          #4

          How does it show in Depends.exe (which comes as a VStudio 6 tool) How do both VC6 and VC7 dll compare in terms of exports using depends ?

          M 1 Reply Last reply
          0
          • M Marcello

            Thank you very much. At least an answer ! But it doesn't work :( This is my definition file for vc70: AutoExp.vcproj, AutoExp.cpp and AutoExp.def are all in the same directory AutoExp.vcproj has AutoExp.cpp and AutoExp.def in itself. Is there, maybe, some options in the project that creates problems ? Cheers, Marcello

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

            Hmmmmmmmmm ... Try not putting the @1, @2 and @3 in the exports section .. see if it helps ?

            M 3 Replies Last reply
            0
            • D darkbyte

              Hmmmmmmmmm ... Try not putting the @1, @2 and @3 in the exports section .. see if it helps ?

              M Offline
              M Offline
              Marcello
              wrote on last edited by
              #6

              Thank ou for all the help. I will try to check what you suggested me tomorrow ! Cheers, Marcello

              1 Reply Last reply
              0
              • D darkbyte

                How does it show in Depends.exe (which comes as a VStudio 6 tool) How do both VC6 and VC7 dll compare in terms of exports using depends ?

                M Offline
                M Offline
                Marcello
                wrote on last edited by
                #7

                What a cool program ! I dodn't know about it ! Thank you ! Under Depends it shows exactly as with dumpbin vc6: it appears as VCF_DateTimeEvaluate vc70: it appears as _VCF_DateTimeEvaluate@28

                1 Reply Last reply
                0
                • D darkbyte

                  Hmmmmmmmmm ... Try not putting the @1, @2 and @3 in the exports section .. see if it helps ?

                  M Offline
                  M Offline
                  Marcello
                  wrote on last edited by
                  #8

                  Tried ! No success !

                  1 Reply Last reply
                  0
                  • D darkbyte

                    Hmmmmmmmmm ... Try not putting the @1, @2 and @3 in the exports section .. see if it helps ?

                    M Offline
                    M Offline
                    Marcello
                    wrote on last edited by
                    #9

                    Problem solved ! I had the feeling that vc70 was not reading this darn definition file, because by changing it it was not asking to rebuild. So I looked around and I found the option: Property Pages > Linker > Input > Module Definition File > and there I put AutoExp.def where the content is: LIBRARY AutoExpEx DESCRIPTION "Implements Custom Evaluator for Microsoft Debugger" EXPORTS VCF_VariantEvaluate @1 It works ! The linker screams both with the DLLEXPORT declaration and/or I do not use the '@' Note that the help in VisualStudio says that we should not specify the file in the environment, only to include it into the project ! But it works. Thanks a lot ! I really appreciated !

                    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