Fixing bug 2862668, "freeglut 2.6.0 RC1 fails to build on FreeBSD", submitted by...
[freeglut] / src / freeglut_input_devices.c
index 0e3dc8d..0e202fa 100755 (executable)
@@ -36,7 +36,9 @@
 #include "freeglut_internal.h"
 
 #if TARGET_HOST_POSIX_X11
+#if HAVE_ERRNO
 #include <errno.h>
+#endif
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include <time.h>
@@ -139,7 +141,7 @@ void fgInitialiseInputDevices ( void )
     if( !fgState.InputDevsInitialised )
     {
       /* will return true for VC8 (VC2005) and higher */
-#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
+#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" );
@@ -166,7 +168,7 @@ void fgInitialiseInputDevices ( void )
         if ( !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 )
+#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);