wincompat.h 2.3 KB

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