Porting Win32 source files to GNU-C

Using __STDCALL (WINAPI)

1 ) Bug in EMX 0.9C:

The new NT09C compiler does not contain this bug. Perhaps the next emxfix package will remove the bug in emx 0.9c.

The emx compiler ignores the attribute STDCALL if you write a typedef line like:

typedef int WINAPI (*DLLFUNC) (int, int);

int main() 
{
  DLLFUNC lpfnDllFunc;
  hLib = LoadLibrary("dlltest.dll");
  lpfnDllFunx = (DLLFUNC) GetProcAddress(hLib, "test");
  (*lpfnDllFunc)(1,2);	/* bad for emx */
}

A save call use a helper function like (example in sample\dll):

static int save_stdcall(DLLFUNC func, int a, int b)
{
  return (*func) (a,b);
}

typedef int WINAPI (*DLLFUNC) (int, int);

int main() 
{
  DLLFUNC lpfnDllFunc;
  hLib = LoadLibrary("dlltest.dll");
  lpfnDllFunx = (DLLFUNC) GetProcAddress(hLib, "test");
  save_stdcall(lpfnDllFunc,1,2);	/* good for emx */
}