CrossplatformDefines.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef CROSSPLATFORMDEFINES_H
  2. #define CROSSPLATFORMDEFINES_H
  3. /////////////////////////////////////////////////////////////////////
  4. //define a consistent warning preprocessor for unix and win systems
  5. // see http://stackoverflow.com/questions/471935/user-warnings-on-msvc-and-gcc
  6. #define STRINGISE_IMPL(x) #x
  7. #define STRINGISE(x) STRINGISE_IMPL(x)
  8. // Use: #pragma message NICE_WARNING("My message")
  9. #if _MSC_VER
  10. # define FILE_LINE_LINK __FILE__ "(" STRINGISE(__LINE__) ") : "
  11. # define NICE_WARNING(exp) (FILE_LINE_LINK "WARNING: " exp)
  12. # define __MESSAGE(text) __pragma( message(__FILE__ "(" STRINGISE(__LINE__) ")" text) )
  13. # define NICE_ERROR(text) __MESSAGE( " : Error: " #text )
  14. # define NICE_MESSAGE(text) __MESSAGE( ": " #text )
  15. //# define TODO(text) WARNING( TODO: text )
  16. //use as:
  17. //ERROR( This will be a compiler error );
  18. //MESSAGE( Well this is what I have to say about this code );
  19. //TODO( Still have to fix 3D rendering );
  20. #else//__GNUC__ - may need other defines for different compilers
  21. # define NICE_WARNING(exp) ("WARNING: " exp)
  22. #endif
  23. //
  24. /////////////////////////////////////////////////////////////////////
  25. /////////////////////////////////////////////////////////////////////
  26. //
  27. #include <math.h>
  28. #ifdef WIN32
  29. typedef unsigned int uint;
  30. inline double round(double r) {
  31. return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
  32. }
  33. inline float roundf(float r)
  34. {
  35. return (float)round(r);
  36. }
  37. #endif
  38. #endif //CROSSPLATFORMDEFINES_H