Q:

Adding an stdcall on a callback function gives an argument mismatch [GNU]

I'm trying to add an stdcall calling convention to my GNU compiled DLL.
Here is my code:
typedef void (__stdcall * CTMCashAcceptCallback) (
    const struct CTMEventInfo,
    const struct CTMAcceptEvent );

It's been called by this function:
LIBCTMCLIENT_FUNC void ctm_add_cash_accept_event_handler(CTMCashAcceptCallback);

where:
#define LIBCTMCLIENT_FUNC LIBCTMCLIENT_C_LINKAGE __declspec(dllexport) __stdcall

The problem is that it gives me this note:
note: expected 'CTMCashAcceptCallback' but argument is of type 'void (*)(const struct CTMEventInfo,  const struct CTMAcceptEvent)'
When I remove the __stdcall or replace it with __cdecl instead, it does not give that information. Is it not possible to use stdcall when compiling through GNU or maybe I'm not doing it right?

A:

The user code needs to explicitly tell the compiler its own function (the one you did not show) to be __stdcall, if that is what the DLL expects. Something like
__stdcall myCTMCashAccept (
   const struct CTMEventInfo,
   const struct CTMAcceptEvent)
{
  //...
}
// ...
  ctm_add_cash_accept_event_handler(myCTMCashAccept);

should work.
Remember that the #define LIBCTMCLIENT_FUNC you showed is about the convention for user code calling the DLL; while the callback, with its typedef, is about the other way: it is the DLL calling the user code. They do not have to use the same conventions (although it is clearer when they do); so if your user code is likely to use __cdecl code (perhaps because it already exists), then you should remove the __stdcall from the typedef (and it should work, too).

