OpenParsec / openparsec

GNU General Public License v2.0
51 stars 8 forks source link

compilation fails on Linux (Debian 11 bullseye) because redefinition of macro "isnan" #57

Closed mattthias closed 2 years ago

mattthias commented 2 years ago

Hi,

on Debian 11 (bullseye) the compilation ( cd platforms/premake ; premake4 gmake ; make config=debug64) fails with the this error:

../../../../src/libparsec/g_telep.cpp: In function 'void Teleporter_Rotation_Transform(float, float, geomv_t (*)[4])':
../../../../src/libparsec/g_telep.cpp:33:18: error: '_isnan' was not declared in this scope; did you mean '__isnan'?
   33 | #define isnan(x) _isnan(x)
      |                  ^~~~~~
../../../../src/libparsec/g_telep.cpp:682:19: note: in expansion of macro 'isnan'
  682 |  if(phi < 0.0f || isnan(phi)) {
      |                   ^~~~~
../../../../src/libparsec/g_telep.cpp:33:18: error: '_isnan' was not declared in this scope; did you mean '__isnan'?
   33 | #define isnan(x) _isnan(x)
      |                  ^~~~~~
../../../../src/libparsec/g_telep.cpp:689:21: note: in expansion of macro 'isnan'
  689 |  if(theta < 0.0f || isnan(theta)) {
      |                     ^~~~~
make[1]: *** [Makefile:467: obj/x64/Debug/g_telep.o] Error 1
make: *** [Makefile:17: client] Error 2

As a workaround I just commented out the three lines in src/libparsec/g_telep.cpp I guess the define is needed for other platforms than Linux? The internet told me that _isnan is a Microsoft specific macro?

--- a/src/libparsec/g_telep.cpp
+++ b/src/libparsec/g_telep.cpp
@@ -29,9 +29,9 @@
 #include <math.h>
 #include <limits.h>

-#ifndef isnan
-#define isnan(x) _isnan(x)
-#endif
+//#ifndef isnan
+//#define isnan(x) _isnan(x)
+//#endif

 // compilation flags/debug support
 #include "config.h"
uberlinuxguy commented 2 years ago

it may have been a universal def but now may only be needed on windows. The compiler is suggesting __isnan... which is interesting. I would investigate that for linux and change up the macros for that and with platform specific detection.

mattthias commented 2 years ago

Wow, fast reaction. While reading through the other issues I just noticed that this was already discussed in https://github.com/OpenParsec/openparsec/issues/55 ..