See e-mail from Martin Payne dated 11/30/09 at 5:51 AM. These changes include changing "HAVE_ERRNO" to "HAVE_ERRNO_H" globally, modifying "configure.ac" to check for "errno.h", and modifying the "vcproj" files to suppress spurious warnings.

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@854 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
fayjf 2009-12-02 03:56:05 +00:00
parent 7efa887c37
commit 103563ac3b
8 changed files with 20 additions and 74 deletions

View File

@ -41,10 +41,9 @@
/> />
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
AdditionalOptions="/D &quot;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES&quot;"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\include" AdditionalIncludeDirectories="..\include"
PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_USRDLL;FREEGLUT_EXPORTS" PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_USRDLL;FREEGLUT_EXPORTS;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="1" RuntimeLibrary="1"
@ -125,7 +124,7 @@
Optimization="2" Optimization="2"
EnableIntrinsicFunctions="true" EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\include" AdditionalIncludeDirectories="..\include"
PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_USRDLL;FREEGLUT_EXPORTS" PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_USRDLL;FREEGLUT_EXPORTS;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="0" RuntimeLibrary="0"
EnableFunctionLevelLinking="true" EnableFunctionLevelLinking="true"
WarningLevel="3" WarningLevel="3"

View File

@ -43,7 +43,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\include" AdditionalIncludeDirectories="..\include"
PreprocessorDefinitions="_DEBUG;FREEGLUT_STATIC;WIN32;_LIB" PreprocessorDefinitions="_DEBUG;FREEGLUT_STATIC;WIN32;_LIB;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="1" RuntimeLibrary="1"
@ -113,7 +113,7 @@
Optimization="2" Optimization="2"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\include" AdditionalIncludeDirectories="..\include"
PreprocessorDefinitions="NDEBUG;FREEGLUT_STATIC;WIN32;_LIB" PreprocessorDefinitions="NDEBUG;FREEGLUT_STATIC;WIN32;_LIB;_CRT_SECURE_NO_WARNINGS"
StringPooling="true" StringPooling="true"
RuntimeLibrary="0" RuntimeLibrary="0"
EnableFunctionLevelLinking="true" EnableFunctionLevelLinking="true"

View File

@ -46,7 +46,7 @@ AC_SUBST([EXPORT_FLAGS])
AC_HEADER_STDC AC_HEADER_STDC
save_CPPFLAGS="$CPPFLAGS" save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $X_CFLAGS" CPPFLAGS="$CPPFLAGS $X_CFLAGS"
AC_CHECK_HEADERS([GL/gl.h GL/glu.h GL/glx.h fcntl.h limits.h sys/ioctl.h sys/param.h sys/time.h]) AC_CHECK_HEADERS([usbhid.h errno.h GL/gl.h GL/glu.h GL/glx.h fcntl.h limits.h sys/ioctl.h sys/param.h sys/time.h])
AC_HEADER_TIME AC_HEADER_TIME
AC_CHECK_HEADERS([X11/extensions/xf86vmode.h], [], [], [#include <X11/Xlib.h>]) AC_CHECK_HEADERS([X11/extensions/xf86vmode.h], [], [], [#include <X11/Xlib.h>])
AC_CHECK_HEADERS([X11/extensions/XI.h X11/extensions/XInput.h]) AC_CHECK_HEADERS([X11/extensions/XI.h X11/extensions/XInput.h])

View File

@ -680,14 +680,6 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
char* geometry = NULL; char* geometry = NULL;
int i, j, argc = *pargc; int i, j, argc = *pargc;
/* will return true for VC8 (VC2005) and higher */
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
size_t sLen;
#if HAVE_ERRNO
errno_t err;
#endif
#endif
if( fgState.Initialised ) if( fgState.Initialised )
fgError( "illegal glutInit() reinitialization attempt" ); fgError( "illegal glutInit() reinitialization attempt" );
@ -707,15 +699,8 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
/* check if GLUT_FPS env var is set */ /* check if GLUT_FPS env var is set */
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
{ {
/* will return true for VC8 (VC2005) and higher */
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
char* fps = NULL;
err = _dupenv_s( &fps, &sLen, "GLUT_FPS" );
if (err)
fgError("Error getting GLUT_FPS environment variable");
#else
const char *fps = getenv( "GLUT_FPS" ); const char *fps = getenv( "GLUT_FPS" );
#endif
if( fps ) if( fps )
{ {
int interval; int interval;
@ -726,20 +711,9 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
else else
fgState.FPSInterval = interval; fgState.FPSInterval = interval;
} }
/* will return true for VC8 (VC2005) and higher */
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
free ( fps ); fps = NULL; /* dupenv_s allocates a string that we must free */
#endif
} }
/* will return true for VC8 (VC2005) and higher */
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
err = _dupenv_s( &displayName, &sLen, "DISPLAY" );
if (err)
fgError("Error getting DISPLAY environment variable");
#else
displayName = getenv( "DISPLAY" ); displayName = getenv( "DISPLAY" );
#endif
for( i = 1; i < argc; i++ ) for( i = 1; i < argc; i++ )
{ {
@ -824,10 +798,6 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
* variable for opening the X display (see code above): * variable for opening the X display (see code above):
*/ */
fghInitialize( displayName ); fghInitialize( displayName );
/* will return true for VC8 (VC2005) and higher */
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
free ( displayName ); displayName = NULL; /* dupenv_s allocates a string that we must free */
#endif
/* /*
* Geometry parsing deffered until here because we may need the screen * Geometry parsing deffered until here because we may need the screen
@ -936,21 +906,13 @@ void FGAPIENTRY glutInitDisplayString( const char* displayMode )
* delimited by blanks or tabs. * delimited by blanks or tabs.
*/ */
char *token ; char *token ;
/* will return true for VC8 (VC2005) and higher */
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
char *next_token = NULL;
#endif
size_t len = strlen ( displayMode ); size_t len = strlen ( displayMode );
char *buffer = (char *)malloc ( (len+1) * sizeof(char) ); char *buffer = (char *)malloc ( (len+1) * sizeof(char) );
memcpy ( buffer, displayMode, len ); memcpy ( buffer, displayMode, len );
buffer[len] = '\0'; buffer[len] = '\0';
/* will return true for VC8 (VC2005) and higher */
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
token = strtok_s ( buffer, " \t", &next_token );
#else
token = strtok ( buffer, " \t" ); token = strtok ( buffer, " \t" );
#endif
while ( token ) while ( token )
{ {
/* Process this token */ /* Process this token */
@ -1127,12 +1089,7 @@ void FGAPIENTRY glutInitDisplayString( const char* displayMode )
break ; break ;
} }
/* will return true for VC8 (VC2005) and higher */
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
token = strtok_s ( NULL, " \t", &next_token );
#else
token = strtok ( NULL, " \t" ); token = strtok ( NULL, " \t" );
#endif
} }
free ( buffer ); free ( buffer );

View File

@ -36,7 +36,7 @@
#include "freeglut_internal.h" #include "freeglut_internal.h"
#if TARGET_HOST_POSIX_X11 #if TARGET_HOST_POSIX_X11
#if HAVE_ERRNO #if HAVE_ERRNO_H
#include <errno.h> #include <errno.h>
#endif #endif
#include <sys/ioctl.h> #include <sys/ioctl.h>
@ -140,17 +140,8 @@ void fgInitialiseInputDevices ( void )
{ {
if( !fgState.InputDevsInitialised ) if( !fgState.InputDevsInitialised )
{ {
/* will return true for VC8 (VC2005) and higher */
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
char *dial_device=NULL;
size_t sLen;
errno_t err = _dupenv_s( &dial_device, &sLen, "GLUT_DIALS_SERIAL" );
if (err)
fgError("Error getting GLUT_DIALS_SERIAL environment variable");
#else
const char *dial_device=NULL; const char *dial_device=NULL;
dial_device = getenv ( "GLUT_DIALS_SERIAL" ); dial_device = getenv ( "GLUT_DIALS_SERIAL" );
#endif
#if TARGET_HOST_MS_WINDOWS #if TARGET_HOST_MS_WINDOWS
if (!dial_device){ if (!dial_device){
static char devname[256]; static char devname[256];
@ -167,10 +158,6 @@ void fgInitialiseInputDevices ( void )
#endif #endif
if ( !dial_device ) return; if ( !dial_device ) return;
if ( !( dialbox_port = serial_open ( dial_device ) ) ) return; if ( !( dialbox_port = serial_open ( dial_device ) ) ) return;
/* will return true for VC8 (VC2005) and higher */
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
free ( dial_device ); dial_device = NULL; /* dupenv_s allocates a string that we must free */
#endif
serial_putchar(dialbox_port,DIAL_INITIALIZE); serial_putchar(dialbox_port,DIAL_INITIALIZE);
glutTimerFunc ( 10, poll_dials, 0 ); glutTimerFunc ( 10, poll_dials, 0 );
fgState.InputDevsInitialised = GL_TRUE; fgState.InputDevsInitialised = GL_TRUE;

View File

@ -75,7 +75,7 @@
# if HAVE_FCNTL_H # if HAVE_FCNTL_H
# include <fcntl.h> # include <fcntl.h>
# endif # endif
# if HAVE_ERRNO # if HAVE_ERRNO_H
# include <errno.h> # include <errno.h>
# endif # endif
# if defined(__FreeBSD__) || defined(__NetBSD__) # if defined(__FreeBSD__) || defined(__NetBSD__)
@ -240,7 +240,7 @@ static int fghJoystickFindUSBdev(char *name, char *out, int outlen)
if (cp) if (cp)
return 1; return 1;
} }
#if HAVE_ERRNO #if HAVE_ERRNO_H
else if (errno == EACCES) { else if (errno == EACCES) {
if (!protection_warned) { if (!protection_warned) {
fgWarning ( "Can't open %s for read!", buf ); fgWarning ( "Can't open %s for read!", buf );
@ -265,7 +265,7 @@ static int fghJoystickInitializeHID(struct os_specific_s *os,
if ( ( rd = hid_get_report_desc( os->fd ) ) == 0 ) if ( ( rd = hid_get_report_desc( os->fd ) ) == 0 )
{ {
#if HAVE_ERRNO #if HAVE_ERRNO_H
fgWarning ( "error: %s: %s", os->fname, strerror( errno ) ); fgWarning ( "error: %s: %s", os->fname, strerror( errno ) );
#else #else
fgWarning ( "error: %s", os->fname ); fgWarning ( "error: %s", os->fname );
@ -279,7 +279,7 @@ static int fghJoystickInitializeHID(struct os_specific_s *os,
if( ioctl( os->fd, USB_GET_REPORT_ID, &report_id ) < 0) if( ioctl( os->fd, USB_GET_REPORT_ID, &report_id ) < 0)
{ {
/*** XXX {report_id} may not be the right variable? ***/ /*** XXX {report_id} may not be the right variable? ***/
#if HAVE_ERRNO #if HAVE_ERRNO_H
fgWarning ( "error: %s%d: %s", UHIDDEV, report_id, strerror( errno ) ); fgWarning ( "error: %s%d: %s", UHIDDEV, report_id, strerror( errno ) );
#else #else
fgWarning ( "error: %s%d", UHIDDEV, report_id ); fgWarning ( "error: %s%d", UHIDDEV, report_id );
@ -676,7 +676,7 @@ static void fghJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
} }
} }
} }
#if HAVE_ERRNO #if HAVE_ERRNO_H
if ( len < 0 && errno != EAGAIN ) if ( len < 0 && errno != EAGAIN )
#else #else
if ( len < 0 ) if ( len < 0 )
@ -699,7 +699,7 @@ static void fghJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
if ( status != sizeof( struct js_event ) ) if ( status != sizeof( struct js_event ) )
{ {
#if HAVE_ERRNO #if HAVE_ERRNO_H
if ( errno == EAGAIN ) if ( errno == EAGAIN )
{ {
/* Use the old values */ /* Use the old values */
@ -1317,7 +1317,7 @@ static void fghJoystickOpen( SFG_Joystick* joy )
joy->os->fd = open( joy->os->fname, O_RDONLY | O_NONBLOCK); joy->os->fd = open( joy->os->fname, O_RDONLY | O_NONBLOCK);
#if HAVE_ERRNO #if HAVE_ERRNO_H
if( joy->os->fd < 0 && errno == EACCES ) if( joy->os->fd < 0 && errno == EACCES )
fgWarning ( "%s exists but is not readable by you", joy->os->fname ); fgWarning ( "%s exists but is not readable by you", joy->os->fname );
#endif #endif

View File

@ -27,7 +27,7 @@
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
#if HAVE_ERRNO #if HAVE_ERRNO_H
# include <errno.h> # include <errno.h>
#endif #endif
#include <stdarg.h> #include <stdarg.h>
@ -473,7 +473,7 @@ static void fghSleepForEvents( void )
wait.tv_usec = (msec % 1000) * 1000; wait.tv_usec = (msec % 1000) * 1000;
err = select( socket+1, &fdset, NULL, NULL, &wait ); err = select( socket+1, &fdset, NULL, NULL, &wait );
#if HAVE_ERRNO #if HAVE_ERRNO_H
if( ( -1 == err ) && ( errno != EINTR ) ) if( ( -1 == err ) && ( errno != EINTR ) )
fgWarning ( "freeglut select() error: %d", errno ); fgWarning ( "freeglut select() error: %d", errno );
#endif #endif

View File

@ -215,7 +215,10 @@ OF SUCH DAMAGE.
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if HAVE_ERRNO_H
#include <errno.h> #include <errno.h>
#endif
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>