WIN32 compilation issues patch

Jorge Santos Simón <[email protected]>
Newsgroups gmane.science.robotics.playerstage
Message-ID <[email protected]>
Hello all,

I have prepared a patch with all the modifications I have done to
player code to successfully compile on windows with Visual Studio
2008.
All modifications should be innocuous for Linux compilation, as they
are all included on precompiler directives of kind:

#if defined WIN32
  ...include some files...
  ...defines missing on windows...
#else
  ...include some others...
#endif

In fact, I have successfully compiled my code on Linux.

I hope the path will work with no problems....  is the first time I
use patch generation tools (by the way, I have used tortoise SVN).
I have tried it on Linux and it works fine for me.

Best regards,
Jorge

------------------------------------------------------------------------------

_______________________________________________
Playerstage-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-developers
win32_compilation_issues.patch (application/octet-stream, 8.7 KB)
Index: libplayerinterface/addr_util.c
===================================================================
--- libplayerinterface/addr_util.c	(revision 8628)
+++ libplayerinterface/addr_util.c	(working copy)
@@ -43,7 +43,7 @@
 #include <assert.h>
 #include <sys/types.h>
 #if defined WIN32
-  #include <Winsock2.h>
+  #include <winsock2.h>
   #define snprintf _snprintf
 #else
   #include <unistd.h>
Index: rtk2/rtk.c
===================================================================
--- rtk2/rtk.c	(revision 8628)
+++ rtk2/rtk.c	(working copy)
@@ -39,7 +39,6 @@
 #include "avcodec.h"
 #endif
 
-//#define DEBUG
 #include "rtk.h"
 #include "rtkprivate.h"
 
@@ -192,7 +191,7 @@
 // Event processing function.  Returns non-zero if the app should quit.
 int rtk_app_main_loop(rtk_app_t *app)
 {
-  int ret;
+  int ret = 0;
   rtk_canvas_t *canvas;
   rtk_table_t *table;
   
Index: rtk2/rtk_fig.c
===================================================================
--- rtk2/rtk_fig.c	(revision 8628)
+++ rtk2/rtk_fig.c	(working copy)
@@ -38,6 +38,10 @@
 #include "rtk.h"
 #include "rtkprivate.h"
 
+#ifndef M_PI
+	#define M_PI 3.14159265358979323846
+#endif
+
 // Draw the selection
 void rtk_fig_render_selection(rtk_fig_t *fig);
 
Index: server/drivers/camera/imageseq/imageseq.cc
===================================================================
--- server/drivers/camera/imageseq/imageseq.cc	(revision 8628)
+++ server/drivers/camera/imageseq/imageseq.cc	(working copy)
@@ -86,19 +86,19 @@
 /** @} */
 
 #include <string.h>
-#include <stdlib.h>
 #include <stddef.h>
 #ifndef WIN32
-#include <unistd.h>
+  #include <unistd.h>
 #endif
 #include <time.h>         // for nanosleep() and struct timespec
 #include <stdlib.h>       // for atoi(3)
 #include <math.h>
 
+#include <libplayercore/playercore.h>
+
 #include <cv.h>
 #include <highgui.h>
 
-#include <libplayercore/playercore.h>
 
 class ImageSeq : public ThreadedDriver
 {
Index: server/drivers/mixed/mricp/include/Timer.h
===================================================================
--- server/drivers/mixed/mricp/include/Timer.h	(revision 8628)
+++ server/drivers/mixed/mricp/include/Timer.h	(working copy)
@@ -20,8 +20,15 @@
 
 #ifndef TIMER_H_
 #define TIMER_H_
-#include <sys/time.h>
+
+#if defined WIN32
+  #include <replace.h>
+  #include <Winsock2.h>  // For struct timeval
+#else
+  #include <sys/time.h>
+#endif
 #include <iostream>
+
 class Timer
 {
 	private:
Index: server/drivers/mixed/mricp/src/map.cpp
===================================================================
--- server/drivers/mixed/mricp/src/map.cpp	(revision 8628)
+++ server/drivers/mixed/mricp/src/map.cpp	(working copy)
@@ -24,6 +24,9 @@
 #include <iostream>
 using namespace std;
 
+#if defined WIN32
+  #define snprintf _snprintf
+#endif
 
 MAP::MAP(char * Mapname, double pixel_size, double map_size)
 {
Index: server/drivers/mixed/mricp/src/mricp_driver.cpp
===================================================================
--- server/drivers/mixed/mricp/src/mricp_driver.cpp	(revision 8628)
+++ server/drivers/mixed/mricp/src/mricp_driver.cpp	(working copy)
@@ -31,11 +31,16 @@
 #include <config.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/time.h>
+#if defined WIN32
+  #define snprintf _snprintf
+#else
+  #include <unistd.h>
+  #include <sys/time.h>
+  #include <termios.h>
+  #include <netinet/in.h>
+#endif
 #include <fcntl.h>
-#include <termios.h>
 #include <cstdio>
-#include <unistd.h>
 #include <cstdlib>
 #include <cstddef>
 #include <cerrno>
@@ -47,7 +52,6 @@
 #include <iostream>
 #include <csignal>
 #include <vector>
-#include <netinet/in.h>
 // Player includes
 #include <libplayercore/playercore.h>
 
Index: server/drivers/planner/wavefront/wavefront.cc
===================================================================
--- server/drivers/planner/wavefront/wavefront.cc	(revision 8628)
+++ server/drivers/planner/wavefront/wavefront.cc	(working copy)
@@ -215,16 +215,18 @@
 #include <string.h>
 #include <stddef.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <assert.h>
 #include <math.h>
 
+#ifndef WIN32
+  #include <unistd.h>
+  #include <sys/time.h>
+#endif
 
 #include <libplayercore/playercore.h>
 #include <libplayerinterface/functiontable.h>
 #include "plan.h"
 
-#include <sys/time.h>
 static double get_time(void);
 //extern "C" { void draw_cspace(plan_t* plan, const char* fname); }
 
Index: utils/playercam/playercam.c
===================================================================
--- utils/playercam/playercam.c	(revision 8628)
+++ utils/playercam/playercam.c	(working copy)
@@ -78,9 +78,15 @@
 
 #include "config.h"
 
-#include <stdint.h>
+#if defined WIN32
+  #include <replace.h>
+  #define strcasecmp _stricmp
+#else
+  #include <stdint.h>
+  #include <unistd.h>
+#endif
+
 #include <assert.h>
-#include <unistd.h>
 #include <math.h>
 #include <string.h>
 #include <stdlib.h>
Index: utils/playernav/gui.c
===================================================================
--- utils/playernav/gui.c	(revision 8628)
+++ utils/playernav/gui.c	(working copy)
@@ -21,7 +21,12 @@
  */
 
 #include <math.h>
-#include <sys/time.h>
+#if defined WIN32
+  #define PATH_MAX 260
+  #define snprintf _snprintf
+#else
+  #include <sys/time.h>
+#endif
 
 #include <gdk/gdkkeysyms.h>
 
Index: utils/playernav/playernav.c
===================================================================
--- utils/playernav/playernav.c	(revision 8628)
+++ utils/playernav/playernav.c	(working copy)
@@ -134,7 +134,9 @@
 #include <signal.h>
 #include <string.h>
 #include <math.h>
-#include <sys/time.h>
+#ifndef WIN32
+  #include <sys/time.h>
+#endif
 
 #include "playernav.h"
 
Index: utils/playerv/opt.h
===================================================================
--- utils/playerv/opt.h	(revision 8628)
+++ utils/playerv/opt.h	(working copy)
@@ -27,6 +27,9 @@
 #ifndef OPT_H
 #define OPT_H
 
+#if defined WIN32
+  #define snprintf _snprintf
+#endif
 
 // Structure describing a single option.
 // This structure is opaque.
Index: utils/playerv/playerv.c
===================================================================
--- utils/playerv/playerv.c	(revision 8628)
+++ utils/playerv/playerv.c	(working copy)
@@ -120,8 +120,13 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <time.h>
+#if defined WIN32
+  #define SIGQUIT 3
+  #include <replace.h>
+#else
+  #include <unistd.h>
+#endif
 #include "playerv.h"
 
 #define GUI_UPDATE_RATE 20.0
Index: utils/playerv/pv_dev_map.c
===================================================================
--- utils/playerv/pv_dev_map.c	(revision 8628)
+++ utils/playerv/pv_dev_map.c	(working copy)
@@ -27,6 +27,9 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#if defined WIN32
+  #include <replace.h>
+#endif
 #include "playerv.h"
 
 
@@ -159,20 +162,21 @@
 
   for( x=0; x<map->proxy->width; x++ )
     for( y=0; y<map->proxy->height; y++ )
+    {
+	  int8_t val = map->proxy->cells[ x + y * map->proxy->width ];
+      if (val != 0)
       {
-	int8_t val = map->proxy->cells[ x + y * map->proxy->width ];
-	if (val == 0)
-	  continue;
-	double color = (double)val/map->proxy->data_range; // scale to[-1,1]
-	color *= -1; //flip sign for coloring occupied to black
-	color = (color+1)/2.0; // scale to [0,1]
-	rtk_fig_color(map->fig, color, color, color );
-	rtk_fig_rectangle(map->fig,
-			  (x - map->proxy->width/2.0) * scale + scale/2.0,
-			  (y - map->proxy->height/2.0) * scale + scale/2.0,
-			  0,
-			  scale, scale, 1);
+        double color = (double)val/map->proxy->data_range; // scale to[-1,1]
+        color *= -1; //flip sign for coloring occupied to black
+        color = (color+1)/2.0; // scale to [0,1]
+        rtk_fig_color(map->fig, color, color, color );
+        rtk_fig_rectangle(map->fig,
+		                  (x - map->proxy->width/2.0) * scale + scale/2.0,
+		                  (y - map->proxy->height/2.0) * scale + scale/2.0,
+		                  0,
+		                  scale, scale, 1);
       }
+    }
 
   return;
 }
Index: utils/pmap/lodo_driver.cc
===================================================================
--- utils/pmap/lodo_driver.cc	(revision 8628)
+++ utils/pmap/lodo_driver.cc	(working copy)
@@ -146,9 +146,11 @@
 
 */
 
-#include <unistd.h>
 #include <string.h>
-#include <netinet/in.h>
+#ifndef WIN32
+  #include <unistd.h>
+  #include <netinet/in.h>
+#endif
 
 #include <libplayercore/playercore.h>
 
Index: utils/pmap/slap.cpp
===================================================================
--- utils/pmap/slap.cpp	(revision 8628)
+++ utils/pmap/slap.cpp	(working copy)
@@ -27,6 +27,10 @@
 #include <math.h>
 #include "slap.h"
 
+#if defined WIN32
+  #include <float.h>
+  #define isnan _isnan
+#endif
 
 /* Set vector elements. */
 vector2_t vector2_set(double v0, double v1)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.