While using a 3rd party shared library i.e. DLL, I have to define the functions usable by their symbol names. So I have to declare some function types.
But the function definition involves a calling convention, in my case __cdecl.
So, naturally, this calling convention is only applicable to the MSVC compiler but I still want to compile my portable API abstraction code, which uses boost::dll with linux, even though I can not execute it on my development linux machine, so I can still check the compile time stuff.
So my idea was to define the __cdecl name to something as nothing or a white space, a NOP if you will, with the pre-processor, but I am not able to do that:
#if !BOOST_OS_WINDOWS
#define __cdecl ( ) /* error, how can I define __cdecl as 'nothing" here? */
#endif
#include <boost/dll/import.hpp>
boost::dll::shared_library lib;
unsigned long device_count(char* pid) {
typedef unsigned long(__cdecl func_sig)(char *pvid_id);
return lib.get<func_sig>("DLL_Symbol")(pid);
}