extern "C" in VisualStudio
-
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 ? -
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 ? -
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.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
-
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
-
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
-
Hmmmmmmmmm ... Try not putting the @1, @2 and @3 in the exports section .. see if it helps ?
-
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 ?
-
Hmmmmmmmmm ... Try not putting the @1, @2 and @3 in the exports section .. see if it helps ?
-
Hmmmmmmmmm ... Try not putting the @1, @2 and @3 in the exports section .. see if it helps ?
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 !