project-navigation
Personal tools

Author Topic: Mac OS X Compile error with possible fix  (Read 3193 times)

Offline zatomic

  • Cannon Fodder
  • **
  • Posts: 2
    • View Profile
Mac OS X Compile error with possible fix
« on: June 20, 2014, 08:03:56 pm »
Hi,

I played this 6 months or so ago. I just checked out the git repository to check out the latest version and maybe find something I can contribute code to. Anyway, I'm running on OS X and have a compile error in the master branch:

Quote
===> CXX [game] src/game/g_ai.cpp
src/game/g_ai.cpp:469:9: error: call to 'abs' is ambiguous
        team = std::abs(team);
               ^~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cmath:660:1: note:
      candidate function
abs(float __x) _NOEXCEPT {return fabsf(__x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cmath:664:1: note:
      candidate function
abs(double __x) _NOEXCEPT {return fabs(__x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cmath:668:1: note:
      candidate function
abs(long double __x) _NOEXCEPT {return fabsl(__x);}
^

I believe the problem is that cstdlib needs to be included in g_ai.cpp as that's where the int version of abs lives. I verified by inserting #include <cstdlib> directly in g_ai.cpp and that fixed it (well, the compile got way past that point before having another issue). I'm not sure where the actual correct place for that include is (somewhere in a header file probably).

Anyway, hopefully I can help out (keeping things compiling on OS X if nothing else).