Borland vs. MSVC Calling Convention
> I'm using a 3rd party app that was written in Delphi. This app allows
> the use of extension DLLs -- you can direct the app to call functions
> in your own custom DLL, subject to the app's specification. I created
> my DLL in VC6, but there is a problem when the 3rd party app tries to
> call a function in the DLL. In VC6, the exported function name gets
> mangled in a way that the Delphi can't recognize.
> I've tried using the extern "C" directive to prevent the mangling, but
> the __stdcall directive also mangles the function names. Not only
> that, but the parameter ordering and stack cleanup must be compatible.
> Has anyone found a way to declare a MSCV exported function so that
> Delphi (or Borland C++) can see (and correctly call) it?
In addition to the other reply, I offer this method which does not involve
redeclaring the function.
An exported function in a DLL can be associated with multiple names.
The multiple aliases come in handy if you want to have a single DLL used by
multiple clients each with their own naming scheme, that is you want to
support both Delphi and VC/C++ clients using the native naming conventions.
All you need to do is use a construct like
in the module definition file. The token on the right side of the equals
sign is the "real" name which you can get by using dumpbin/exports. On the
left side is the alias.