win32.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. // -*- C++ -*-
  2. // Module: Log4CPLUS
  3. // File: config-win32.h
  4. // Created: 4/2003
  5. // Author: Tad E. Smith
  6. //
  7. //
  8. // Copyright 2003-2015 Tad E. Smith
  9. //
  10. // Licensed under the Apache License, Version 2.0 (the "License");
  11. // you may not use this file except in compliance with the License.
  12. // You may obtain a copy of the License at
  13. //
  14. // http://www.apache.org/licenses/LICENSE-2.0
  15. //
  16. // Unless required by applicable law or agreed to in writing, software
  17. // distributed under the License is distributed on an "AS IS" BASIS,
  18. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. // See the License for the specific language governing permissions and
  20. // limitations under the License.
  21. /** @file */
  22. #ifndef LOG4CPLUS_CONFIG_WIN32_HEADER_
  23. #define LOG4CPLUS_CONFIG_WIN32_HEADER_
  24. #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
  25. #pragma once
  26. #endif
  27. #if defined (__MINGW32__) || defined (__MINGW64__)
  28. # include <_mingw.h>
  29. #endif
  30. #ifdef _WIN32
  31. #if (defined (_MSC_VER) && _MSC_VER > 1400) \
  32. || (defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 3)
  33. # define LOG4CPLUS_HAVE_INTRIN_H
  34. #endif
  35. // Time related functions and headers.
  36. #define LOG4CPLUS_HAVE_TIME_H
  37. #define LOG4CPLUS_HAVE_SYS_TIMEB_H
  38. #define LOG4CPLUS_HAVE_FTIME
  39. #if defined (_MSC_VER) || defined (__BORLANDC__)
  40. #define LOG4CPLUS_HAVE_GMTIME_S
  41. #endif
  42. // Use Winsock on Windows.
  43. #define LOG4CPLUS_USE_WINSOCK
  44. // Enable Win32DebugAppender
  45. #define LOG4CPLUS_HAVE_OUTPUTDEBUGSTRING
  46. // Enable Win32ConsoleAppender.
  47. #define LOG4CPLUS_HAVE_WIN32_CONSOLE
  48. #define LOG4CPLUS_HAVE_SYS_TYPES_H
  49. #define LOG4CPLUS_HAVE_SYS_LOCKING_H
  50. #define LOG4CPLUS_HAVE_FCNTL_H
  51. #define LOG4CPLUS_HAVE_IO_H
  52. #define LOG4CPLUS_HAVE_STDIO_H
  53. #define LOG4CPLUS_HAVE_WCHAR_H
  54. #define LOG4CPLUS_HAVE_STDARG_H
  55. #define LOG4CPLUS_HAVE_STDLIB_H
  56. #define LOG4CPLUS_HAVE_ERRNO_H
  57. #define LOG4CPLUS_HAVE_SYS_STAT_H
  58. #define LOG4CPLUS_HAVE_TIME_H
  59. #define LOG4CPLUS_HAVE_STDLIB_H
  60. #define LOG4CPLUS_HAVE_DIRECT_H
  61. // MSVC has both and so does MinGW.
  62. #define LOG4CPLUS_HAVE_VSNPRINTF
  63. #define LOG4CPLUS_HAVE__VSNPRINTF
  64. #define LOG4CPLUS_HAVE__VSNWPRINTF
  65. // Limit the use of foo_s() functions to builds using Visual Studio
  66. // 2005 and its run time library. In MinGW land, limit the foo_s()
  67. // functions to MinGw-w64 toolchain and __MSVCRT_VERSION__ >= 0x0900.
  68. #if (defined (_MSC_VER) && _MSC_VER >= 1400) \
  69. || (defined (__MSVCRT_VERSION__) && __MSVCRT_VERSION__ >= 0x0900 \
  70. && defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 2)
  71. // MS secure versions of vprintf().
  72. # define LOG4CPLUS_HAVE_VSPRINTF_S
  73. # define LOG4CPLUS_HAVE_VSWPRINTF_S
  74. // MS secure versions of vfprintf().
  75. # define LOG4CPLUS_HAVE_VFPRINTF_S
  76. # define LOG4CPLUS_HAVE_VFWPRINTF_S
  77. // MS secure versions of vsnprintf().
  78. # define LOG4CPLUS_HAVE_VSNPRINTF_S
  79. # define LOG4CPLUS_HAVE__VSNPRINTF_S
  80. # define LOG4CPLUS_HAVE__VSNWPRINTF_S
  81. // MS secure version of _tsopen().
  82. # define LOG4CPLUS_HAVE__TSOPEN_S
  83. #endif
  84. #if defined (_MSC_VER) && _MSC_VER >= 1400
  85. // MS printf-like functions supporting positional parameters.
  86. # define LOG4CPLUS_HAVE__VSPRINTF_P
  87. # define LOG4CPLUS_HAVE__VSWPRINTF_P
  88. #endif
  89. #define LOG4CPLUS_HAVE__TSOPEN
  90. #define LOG4CPLUS_DLLMAIN_HINSTANCE HINSTANCE
  91. #define LOG4CPLUS_HAVE_NT_EVENT_LOG
  92. // log4cplus_EXPORTS is used by the CMake build system. DLL_EXPORT is
  93. // used by the autotools build system.
  94. #if (defined (log4cplus_EXPORTS) || defined (log4cplusU_EXPORTS) \
  95. || defined (DLL_EXPORT)) \
  96. && ! defined (LOG4CPLUS_STATIC)
  97. # undef LOG4CPLUS_BUILD_DLL
  98. # define LOG4CPLUS_BUILD_DLL
  99. #endif
  100. #if ! defined (LOG4CPLUS_BUILD_DLL)
  101. # undef LOG4CPLUS_STATIC
  102. # define LOG4CPLUS_STATIC
  103. #endif
  104. #if defined (LOG4CPLUS_STATIC) && defined (LOG4CPLUS_BUILD_DLL)
  105. # error LOG4CPLUS_STATIC and LOG4CPLUS_BUILD_DLL cannot be defined both.
  106. #endif
  107. #if defined (LOG4CPLUS_BUILD_DLL)
  108. # if defined (INSIDE_LOG4CPLUS)
  109. # define LOG4CPLUS_EXPORT __declspec(dllexport)
  110. # else
  111. # define LOG4CPLUS_EXPORT __declspec(dllimport)
  112. # endif
  113. #else
  114. # define LOG4CPLUS_EXPORT
  115. #endif
  116. #ifndef LOG4CPLUS_SINGLE_THREADED
  117. # define LOG4CPLUS_USE_WIN32_THREADS
  118. #endif
  119. #if defined (_WIN32_WINNT) && _WIN32_WINNT < 0x0600
  120. # define LOG4CPLUS_POOR_MANS_SHAREDMUTEX
  121. #endif
  122. #if defined(_MSC_VER)
  123. // Warning about: identifier was truncated to '255' characters in the debug information
  124. # pragma warning( disable : 4786 )
  125. // Warning about: <type1> needs to have dll-interface to be used by clients of class <type2>
  126. # pragma warning( disable : 4251 )
  127. # define LOG4CPLUS_INLINES_ARE_EXPORTED
  128. # if _MSC_VER >= 1400
  129. # define LOG4CPLUS_WORKING_LOCALE
  130. # define LOG4CPLUS_HAVE_FUNCTION_MACRO
  131. # define LOG4CPLUS_HAVE_FUNCSIG_MACRO
  132. # define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS
  133. # define LOG4CPLUS_ATTRIBUTE_NORETURN __declspec(noreturn)
  134. # endif
  135. # if _MSC_VER >= 1700
  136. # define LOG4CPLUS_HAVE_CXX11_ATOMICS
  137. # define LOG4CPLUS_WITH_CXX11_THREADS
  138. # endif
  139. #endif
  140. #if defined (__GNUC__)
  141. # undef LOG4CPLUS_INLINES_ARE_EXPORTED
  142. # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
  143. # define LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO
  144. # define LOG4CPLUS_HAVE_FUNC_SYMBOL
  145. # endif
  146. # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
  147. # if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
  148. # define LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH
  149. # define LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH
  150. # endif
  151. # endif
  152. # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
  153. # if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
  154. # define LOG4CPLUS_HAVE___ATOMIC_ADD_FETCH
  155. # define LOG4CPLUS_HAVE___ATOMIC_SUB_FETCH
  156. # endif
  157. // This has worked for some versions of MinGW with GCC 4.7+ but it
  158. // appears to be broken again in 4.8.x. Thus, we disable this for GCC
  159. // completely forever.
  160. //
  161. //# define LOG4CPLUS_INLINES_ARE_EXPORTED
  162. # endif
  163. # define LOG4CPLUS_HAVE_FUNCTION_MACRO
  164. # define LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS
  165. # define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS
  166. # if defined (__MINGW32__)
  167. # define LOG4CPLUS_WORKING_C_LOCALE
  168. # endif
  169. #endif
  170. #if defined (__BORLANDC__) && __BORLANDC__ >= 0x0650
  171. # define LOG4CPLUS_HAVE_FUNCTION_MACRO
  172. # define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS
  173. #endif // __BORLANDC__
  174. #if ! defined (LOG4CPLUS_DISABLE_DLL_RUNTIME_WARNING)
  175. # if defined (LOG4CPLUS_STATIC) && defined (_MSC_VER) && ! defined (_DLL)
  176. # pragma message("You are not using DLL C run time library. " \
  177. "You must call log4cplus::initialize() once before " \
  178. "you use any other log4cplus API.")
  179. # endif
  180. #endif
  181. #endif // _WIN32
  182. #endif // LOG4CPLUS_CONFIG_WIN32_HEADER_