From 81f7f85ade2f873ebee9afa3ad810046771cb5c3 Mon Sep 17 00:00:00 2001 From: Joe Krahn Date: Tue, 26 Sep 2006 03:18:18 +0000 Subject: [PATCH] Added FREEGLUT_LIB_PRAGMAS to control MS library pragmas, and fixed NOMINMAX define. git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@711 7f0cb862-5218-0410-a997-914c9d46530a --- include/GL/freeglut_std.h | 64 ++++++++++++++++++++++++--------------------- src/freeglut_joystick.c | 4 +-- src/freeglut_state.c | 5 +++- src/freeglut_window.c | 7 ++--- 4 files changed, 44 insertions(+), 36 deletions(-) diff --git a/include/GL/freeglut_std.h b/include/GL/freeglut_std.h index c9bb753..15b113f 100644 --- a/include/GL/freeglut_std.h +++ b/include/GL/freeglut_std.h @@ -35,61 +35,65 @@ /* * Under windows, we have to differentiate between static and dynamic libraries */ -#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__WATCOMC__) - +#ifdef _WIN32 /* #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 - */ + */ + +/* 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__) ) && !defined(_WIN32_WCE) +# define FREEGLUT_LIB_PRAGMAS 1 +# else +# define FREEGLUT_LIB_PRAGMAS 0 +# endif +# endif # define WIN32_LEAN_AND_MEAN -# define NO_MIN_MAX -# include -# undef min -# undef max +# define NOMINMAX +# include /* Windows static library */ # ifdef FREEGLUT_STATIC -# define FGAPI -# define FGAPIENTRY +# define FGAPI +# define FGAPIENTRY /* Link with Win32 static freeglut lib */ -# if defined(_MSC_VER) || defined(__WATCOMC__) +# if FREEGLUT_LIB_PRAGMAS # pragma comment (lib, "freeglut_static.lib") # endif /* Windows shared library (DLL) */ # else -# if defined(FREEGLUT_EXPORTS) -# define FGAPI __declspec(dllexport) -# else -# define FGAPI __declspec(dllimport) +# define FGAPIENTRY __stdcall +# if defined(FREEGLUT_EXPORTS) +# define FGAPI __declspec(dllexport) +# else +# define FGAPI __declspec(dllimport) - /* link with Win32 shared freeglut lib */ -# if defined(_MSC_VER) || defined(__WATCOMC__) -# ifndef _WIN32_WCE -# pragma comment (lib, "freeglut.lib") -# endif -# endif + /* Link with Win32 shared freeglut lib */ +# if FREEGLUT_LIB_PRAGMAS +# pragma comment (lib, "freeglut.lib") +# endif # endif -# define FGAPIENTRY __stdcall - # endif /* Drag in other Windows libraries as required by FreeGLUT */ -# if defined(_MSC_VER) || defined(__WATCOMC__) -# ifndef _WIN32_WCE -# pragma comment (lib, "winmm.lib") /* link Windows MultiMedia lib */ -# pragma comment (lib, "user32.lib") /* link Windows user lib */ -# pragma comment (lib, "gdi32.lib") /* link Windows GDI lib */ -# pragma comment (lib, "opengl32.lib") /* link Microsoft OpenGL lib */ -# pragma comment (lib, "glu32.lib") /* link OpenGL Utility lib */ -# endif /* _WIN32_WCE */ +# if FREEGLUT_LIB_PRAGMAS +# pragma comment (lib, "glu32.lib") /* link OpenGL Utility lib */ +# pragma comment (lib, "opengl32.lib") /* link Microsoft OpenGL lib */ +# pragma comment (lib, "gdi32.lib") /* link Windows GDI lib */ +# pragma comment (lib, "winmm.lib") /* link Windows MultiMedia lib */ +# pragma comment (lib, "user32.lib") /* link Windows user lib */ # endif #else diff --git a/src/freeglut_joystick.c b/src/freeglut_joystick.c index f19c5b2..e4bd53b 100644 --- a/src/freeglut_joystick.c +++ b/src/freeglut_joystick.c @@ -979,8 +979,8 @@ static void fghJoystickAddHatElement ( SFG_Joystick *joy, CFDictionaryRef button /* Inspired by http://msdn.microsoft.com/archive/en-us/dnargame/html/msdn_sidewind3d.asp */ -# if defined(_MSC_VER) -# pragma comment (lib, "advapi32.lib") /* library pragmas are bad */ +# if FREEGLUT_LIB_PRAGMAS +# pragma comment (lib, "advapi32.lib") # endif static int fghJoystickGetOEMProductName ( SFG_Joystick* joy, char *buf, int buf_sz ) diff --git a/src/freeglut_state.c b/src/freeglut_state.c index 48ff9a3..45513cd 100644 --- a/src/freeglut_state.c +++ b/src/freeglut_state.c @@ -503,7 +503,10 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat ) */ #if defined(_WIN32_CE) return ( GetKeyboardStatus() & KBDI_KEYBOARD_PRESENT ) ? 1 : 0; -# pragma comment (lib,"Kbdui.lib") +# if FREEGLUT_LIB_PRAGMAS +# pragma comment (lib,"Kbdui.lib") +# endif + #else return 1; #endif diff --git a/src/freeglut_window.c b/src/freeglut_window.c index 0d2705a..325005a 100644 --- a/src/freeglut_window.c +++ b/src/freeglut_window.c @@ -29,8 +29,10 @@ #include "freeglut_internal.h" #if defined(_WIN32_WCE) -#include -#pragma comment( lib, "Aygshell.lib" ) /* library pragmas are bad */ +# include +# ifdef FREEGLUT_LIB_PRAGMAS +# pragma comment( lib, "Aygshell.lib" ) +# endif static wchar_t* fghWstrFromStr(const char* str) { @@ -42,7 +44,6 @@ static wchar_t* fghWstrFromStr(const char* str) return wstr; } - #endif /* defined(_WIN32_WCE) */ /* -- 1.7.10.4