Added FREEGLUT_LIB_PRAGMAS to control MS library pragmas, and fixed NOMINMAX define.
authorJoe Krahn <jkrahn@nc.rr.com>
Tue, 26 Sep 2006 03:18:18 +0000 (03:18 +0000)
committerJoe Krahn <jkrahn@nc.rr.com>
Tue, 26 Sep 2006 03:18:18 +0000 (03:18 +0000)
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
src/freeglut_joystick.c
src/freeglut_state.c
src/freeglut_window.c

index c9bb753..15b113f 100644 (file)
 /*
  * 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 <windows.h>
-#   undef min
-#   undef max
+#   define NOMINMAX
+#   include <Windows.h>
 
 /* 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
index f19c5b2..e4bd53b 100644 (file)
@@ -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 )
index 48ff9a3..45513cd 100644 (file)
@@ -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
index 0d2705a..325005a 100644 (file)
 #include "freeglut_internal.h"
 
 #if defined(_WIN32_WCE)
-#include <aygshell.h>
-#pragma comment( lib, "Aygshell.lib" ) /* library pragmas are bad */
+#   include <Aygshell.h>
+#   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) */
 
 /*