Forced __cdecl underscore

My company provides a third-party DLL group that provides them with API functions that they can use to connect to our application. The DLL was written in VC9, and the API functions use the default VC calling convention (__cdecl). A third party has built their application around this interface.

Now I am tasked with writing an updated version of the DLL. We want the DLL to have the same interface as the old one, so they can be used interchangeably. Unfortunately, our development environment is CodeGear RAD Studio 2007, so I have to write a DLL using this.

The best solution would be to make both old and new DLL files export their functions as __stdcall. Then the third-party application can be re-associated with the expected __stdcall functions and everyone will be happy. Unfortunately, for various reasons, this is unlikely to happen.

Alternatively, I can declare functions in my DLL as __cdecl. A third party expects a __cdecl function, so this would be a good solution. Unfortunately, CodeGear insists on adding an underscore ('_') to the __cdecl function name. This means that a third-party application will have to conditionally call MyApiFunction(...)or _MyApiFunction(...), depending on the DLL used.

So my question is: how can I export API functions from my new DLL so that they are __cdecl and have no underscore ('_') prefix?

+5
source share
3 answers

You should use the .DEF file:

EXPORTS
    HTMLayoutClassNameA = HTMLayoutClassNameA
    HTMLayoutClassNameW = HTMLayoutClassNameW
    HTMLayoutClipboardCopy = HTMLayoutClipboardCopy
    ...

Here we have

externalname = internalname 
+7
source

The Borland C / C ++ compiler has the ability to enable or disable underline underscores. -u(default) generates underscores for character names. Add -u-to the command line and see if that helps. (I'm not sure where to do this in CodeRad, but I almost certainly remember that it can be done somewhere in the IDE).

0
source

-vu-, bcc

0

All Articles