Configuring GMP for Win32 DLL creation

White, Jim (ITD) Jim.White@DEFRA.GSI.GOV.UK
Tue, 3 Jun 2003 15:43:11 +0100


In a separate message, I described how I was able to call pre-built Windows
GMP DLL's successfully from Visual Basic. 

When GMP is configured to build Windows DLL's, the DLL's it produces can
only be called by programs that use the Unix/C calling convention "cdecl". 

Most users of a GMP DLL will probably be in an environment that, like the
Windows API, uses the Pascal calling convention, which in Windows is called
"stdcall". Windows "C" compilers allow the programmer to select either mode
when defining external entry points, so they do not have a problem.

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

While there are workarounds (as I discuss in my previous message), it would
be my suggestion that the standard GMP offer a directive that includes the
"_stdcall" keyword (which I believe is standard in gcc and lcc).

For example, it could be an option "WIN32DLL":

#if defined (_WIN32DLL) 
#define __GMP_DECLSPEC_EXPORT  _stdcall __declspec(dllexport)
#define __GMP_DECLSPEC_IMPORT  _stdcall __declspec(dllimport)
#endif


A GMP dll built with stdcall becomes usable by ANY win32 programming
language


Cheers

Dr Memory