wincompat.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* ----------------------------------------------------------------------------
  2. libconfig - A library for processing structured configuration files
  3. Copyright (C) 2005-2010 Mark A Lindner
  4. This file is part of libconfig.
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with this library; if not, see
  15. <http://www.gnu.org/licenses/>.
  16. ----------------------------------------------------------------------------
  17. */
  18. #ifndef __wincompat_h
  19. #define __wincompat_h
  20. #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
  21. #ifdef _MSC_VER
  22. #pragma warning (disable: 4996)
  23. #endif
  24. #define WIN32_LEAN_AND_MEAN
  25. #include <windows.h>
  26. #define snprintf _snprintf
  27. #ifndef __MINGW32__
  28. #define atoll _atoi64
  29. #define strtoull _strtoui64
  30. #endif /* __MINGW32__ */
  31. #endif
  32. #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
  33. || defined(__MINGW32__))
  34. /* Why does gcc on MinGW use the Visual C++ style format directives
  35. * for 64-bit integers? Inquiring minds want to know....
  36. */
  37. #define INT64_FMT "%I64d"
  38. #define UINT64_FMT "%I64u"
  39. #define INT64_HEX_FMT "%I64X"
  40. #define FILE_SEPARATOR "\\"
  41. #else /* defined(WIN32) || defined(__MINGW32__) */
  42. #define INT64_FMT "%lld"
  43. #define UINT64_FMT "%llu"
  44. #define INT64_HEX_FMT "%llX"
  45. #define FILE_SEPARATOR "/"
  46. #endif /* defined(WIN32) || defined(__MINGW32__) */
  47. #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \
  48. && ! defined(__MINGW32__)
  49. #define INT64_CONST(I) (I ## i64)
  50. #define UINT64_CONST(I) (I ## Ui64)
  51. #ifndef INT32_MAX
  52. #define INT32_MAX (2147483647)
  53. #endif
  54. #ifndef INT32_MIN
  55. #define INT32_MIN (-2147483647-1)
  56. #endif
  57. #else /* defined(WIN32) && ! defined(__MINGW32__) */
  58. #define INT64_CONST(I) (I ## LL)
  59. #define UINT64_CONST(I) (I ## ULL)
  60. #endif /* defined(WIN32) && ! defined(__MINGW32__) */
  61. #endif /* __wincompat_h */