From: Joe Krahn <krahn@ni...> - 2006-09-24 19:04:21
freeglut_std.h includes this comment:
/* #pragma may not be supported by some compilers.
* Discussion by FreeGLUT developers suggests that
* Visual C++ specific code involving pragmas may
* need to move to a separate header. 24th Dec 2003
All ANSI/ISO compilers should support the pragma keyword, but commonly
will not support specific pragmas. So, the library pragmas should never
cause a problem if they are skipped by a conditional.
In order to both support library pragmas and avoid problems, I propose
something like the following code:
/* Define FREEGLUT_LIB_PRAGMAS to 1 to include library
* pragmas or to 1 to exclude library pragmas.
* The default behavior depends on the compiler/platform.
# ifndef FREEGLUT_LIB_PRAGMAS
# if ( defined(_MSC_VER) || defined(__WATCOMC__) )
# define FREEGLUT_LIB_PRAGMAS 1
# define FREEGLUT_LIB_PRAGMAS 0
# pragma comment (lib,...)
Then, all library pragmas can be included or excluded explicitly any
time it causes a problem, and are otherwise included only where it is
expected to work based on specific compiler pre-defines.
Also, I've realized why FreeGLUT uses defines as 0 or 1 instead of
defined or undefined: The code looks cleaner using "XXX" instead of
"defined(XXX)", because a simple #ifdef does not always work.