Configuring GMP for Win32 DLL creation

White, Jim (ITD) Jim.White@DEFRA.GSI.GOV.UK
Wed, 4 Jun 2003 16:43:25 +0100


I wrote:

> But other Win32 language environments, like Visual Basic (VB), Pascal,
> delphi, etc will probably be unable to use a cdecl DLL.

Kevin Ryde <user42@zip.com.au> wrote:

>> Sounds like a significant failing on their part.  Are you sure they're
>> completely unable to do cdecl?


I can only speak with certainty for Visual Basic, which definitely does 
not like cdecl calls - it won't generate the stack cleanup code and has
no option to do so.  VB does have a nice little trick in its IDE whereby
it checks the stack pointer after a DLL call and raises an error 
"Bad DLL calling convention" if it isn't what it should be.

For other languages, whether or not they offer an option to call DLL's
using cdecl I can't be sure.  I have a useful compiler called PowerBasic,
which is really a "C" compiler for lazy people (like me) who want to
write VB-like syntax but also use "C"-style niceties like pointers, 
inline assembler, etc.  It's sort of a VB/C hybrid.  But it also lets
you build DLL's easily, and it has a "Cdecl" option for external entry point

declarations. (I don't know if Delphi/Pascal or other Win32 languages
have this option).

My current solution is to use PowerBasic to make a DLL which I can
call from VB - the PowerBasic dll simply routes the calls using
Cdecl to deltatrinity's DLL.


>From what Kevin and others are saying, it sounds like my suggestion to
be able to configure a GMP build that would create a Win32 stdcall dll
is difficult and probably not wortwhile.

It would probably be easier for GMP to simply generate a separate
gateway DLL offering stdcall entry points, just like the one I'm using.


Cheers

Jim White