Complex C typedef decl replacement

Andrey andr-sar at yandex.ru
Fri Nov 23 07:02:37 PST 2012


Thank you for the reply. I guess, I should have added this before.


#if !defined(OPENSTEP) && (defined(__WIN32__) && 
!defined(__CYGWIN__))
#  if (defined(_MSC_VER) || defined(__MINGW32__)) && 
defined(BUILD_GL32)

/* tag specify we're building mesa as a DLL */

#    define GLAPI __declspec(dllexport)
#  elif (defined(_MSC_VER) || defined(__MINGW32__)) && 
defined(_DLL)

/* tag specifying we're building for DLL runtime support */

#    define GLAPI __declspec(dllimport)
#  else /* for use with static link lib build of Win32 edition 
only */
#    define GLAPI extern
#  endif /* _STATIC_MESA support */
#  if defined(__MINGW32__) && defined(GL_NO_STDCALL) || 
defined(UNDER_CE)

/* The generated DLLs by MingW with STDCALL are not compatible 
with the ones done by Microsoft's compilers */

#    define GLAPIENTRY
#  else
#    define GLAPIENTRY __stdcall
#  endif
#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native 
windows opengl32 */
#  define GLAPI extern
#  define GLAPIENTRY __stdcall
#elif (defined(__GNUC__) && __GNUC__ >= 4) || 
(defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
#  define GLAPI __attribute__((visibility("default")))
#  define GLAPIENTRY
#endif /* WIN32 && !CYGWIN */

#if (defined(__BEOS__) && defined(__POWERPC__)) || 
defined(__QUICKDRAW__)
#  define PRAGMA_EXPORT_SUPPORTED		1
#endif

/*
  * WINDOWS: Include windows.h here to define APIENTRY.
  * It is also useful when applications include this file by
  * including only glut.h, since glut.h depends on windows.h.
  * Applications needing to include windows.h with parms other
  * than "WIN32_LEAN_AND_MEAN" may include windows.h before
  * glut.h or gl.h.
  */
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
#endif

#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED
#pragma import on
#endif

#ifndef GLAPI
#define GLAPI extern
#endif

#ifndef GLAPIENTRY
#define GLAPIENTRY
#endif

#ifndef APIENTRY
#define APIENTRY GLAPIENTRY
#endif

/* "P" suffix to be used for a pointer to a function */
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif

Anyway, I don't understand C macro magic much and can't figure 
out, what exactly they do.

Even if I process the macros, what should I expect from those 
typedefs? Simple functions?


More information about the Digitalmars-d-learn mailing list