wincompat.h 2.3 KB

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