title: Calling convention "defines" without #define
body: <p>In Microsoft's WinDef.h several #defines for callbacks are introduced:</p>
  
  <pre><code>#ifdef _MAC
  #define CALLBACK    PASCAL
  #define WINAPI      CDECL
  #define WINAPIV     CDECL
  #define APIENTRY    WINAPI
  #define APIPRIVATE  CDECL
  #ifdef _68K_
  #define PASCAL      __pascal
  #else
  #define PASCAL
  #endif
  #elif (_MSC_VER &gt;= 800) || defined(_STDCALL_SUPPORTED)
  #define CALLBACK    __stdcall
  #define WINAPI      __stdcall
  #define WINAPIV     __cdecl
  #define APIENTRY    WINAPI
  #define APIPRIVATE  __stdcall
  #define PASCAL      __stdcall
  #else
  #define CALLBACK
  #define WINAPI
  #define WINAPIV
  #define APIENTRY    WINAPI
  #define APIPRIVATE
  #define PASCAL      pascal
  #endif
  </code></pre>
  
  <p>Is there a way to do something like that without preprocessor macros?
  I would like to have something, that resolves to different calling conventions on Unix and Windows, but which - unlike a macro - can be namespaced.</p>
  
  <p>I have tried "typedef __stdcall test;" but that doesn't compile.</p>
  
  <p>EDIT - here is an example usage scenario:</p>
  
  <pre><code>namespace Thread
  {
      typedef startRoutineReturnType (startRoutineCallingConvention *startRoutineCallback)(void* pArg);
  }
  
  Thread::startRoutineReturnType Thread::startRoutineCallingConvention startRoutine(void* pArg);
  </code></pre>
  
  <p>This way startRoutine can confirm to the signature of that callback on all platforms although the calling convention of the callback differs between platforms.
  When there is the possibility that a lot of functions have to confirm to that callback signature then something like</p>
  
  <pre><code>#ifdef UNIX
      void* foo(void* pArg)
  #elif WINDOWS
      DWORD WINAPI foo(LPVOID pArg)
  #else
      // something else
  #endif
  {
      // body
  }
  </code></pre>
  
  <p>instead looks quite messy.</p>