I was playing around with Celestar's multistop patch, trying to compile it under msvc6. After some issues with variable declaration(*) I encountered an issue with calling conventions for callback functions.
Specifically, the vc project is now set to declare all functions as __fastcall. But, in Celestar's code, qsort is used, which expects it's callback to be of __cdecl convention.
I see two obvious solutions to this:
1. Change the project options to use __cdecl by default (I think this is msvc default). Downside to this would be speed, at least I assume __fastcall is faster?
2. Declare all callbacks with an explicit __cdecl. Since __cdecl is only understood by msvc (at least not by gcc), we would need a macro in the form of:
Code: Select all
#ifdef MSVC
#define CALLBACK __cdecl
#else
#define CALLBACK
#endif
(...)
int CALLBACK function(void*, void*) {
(...)
}
Matthijs
(*) When you declare variables, you should only do it at the beginning of a scope (ie any {} block). If you declare a variable after a normal statement, msvc will barf.