win32.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. // -*- C++ -*-
  2. // Module: Log4CPLUS
  3. // File: config-win32.h
  4. // Created: 4/2003
  5. // Author: Tad E. Smith
  6. //
  7. //
  8. // Copyright 2003-2017 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. #if defined (_MSC_VER)
  90. # define LOG4CPLUS_HAVE_LOCALTIME_S
  91. #endif
  92. #define LOG4CPLUS_HAVE__TSOPEN
  93. #define LOG4CPLUS_DLLMAIN_HINSTANCE HINSTANCE
  94. #define LOG4CPLUS_HAVE_NT_EVENT_LOG
  95. // log4cplus_EXPORTS is used by the CMake build system. DLL_EXPORT is
  96. // used by the autotools build system.
  97. #if (defined (log4cplus_EXPORTS) || defined (log4cplusU_EXPORTS) \
  98. || (defined (DLL_EXPORT) && defined (INSIDE_LOG4CPLUS))) \
  99. && ! defined (LOG4CPLUS_STATIC)
  100. # undef LOG4CPLUS_BUILD_DLL
  101. # define LOG4CPLUS_BUILD_DLL
  102. #endif
  103. #if ! defined (LOG4CPLUS_BUILD_DLL)
  104. # undef LOG4CPLUS_STATIC
  105. # define LOG4CPLUS_STATIC
  106. #endif
  107. #if defined (LOG4CPLUS_STATIC) && defined (LOG4CPLUS_BUILD_DLL)
  108. # error LOG4CPLUS_STATIC and LOG4CPLUS_BUILD_DLL cannot be defined both.
  109. #endif
  110. #if defined (LOG4CPLUS_BUILD_DLL)
  111. # if defined (INSIDE_LOG4CPLUS)
  112. # define LOG4CPLUS_EXPORT __declspec(dllexport)
  113. # else
  114. # define LOG4CPLUS_EXPORT __declspec(dllimport)
  115. # endif
  116. #else
  117. # define LOG4CPLUS_EXPORT
  118. #endif
  119. #ifndef LOG4CPLUS_SINGLE_THREADED
  120. # define LOG4CPLUS_USE_WIN32_THREADS
  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_ATTRIBUTE_NORETURN __declspec(noreturn)
  133. # endif
  134. #endif
  135. #if defined (__GNUC__)
  136. # undef LOG4CPLUS_INLINES_ARE_EXPORTED
  137. # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
  138. # define LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO
  139. # define LOG4CPLUS_HAVE_FUNC_SYMBOL
  140. # endif
  141. // This has worked for some versions of MinGW with GCC 4.7+ but it
  142. // appears to be broken again in 4.8.x. Thus, we disable this for GCC
  143. // completely forever.
  144. //
  145. //# define LOG4CPLUS_INLINES_ARE_EXPORTED
  146. # define LOG4CPLUS_HAVE_FUNCTION_MACRO
  147. # if defined (__MINGW32__)
  148. # define LOG4CPLUS_WORKING_C_LOCALE
  149. # endif
  150. #endif
  151. #if defined (__BORLANDC__) && __BORLANDC__ >= 0x0650
  152. # define LOG4CPLUS_HAVE_FUNCTION_MACRO
  153. #endif // __BORLANDC__
  154. #if ! defined (LOG4CPLUS_DISABLE_DLL_RUNTIME_WARNING)
  155. # if defined (LOG4CPLUS_STATIC) && defined (_MSC_VER) && ! defined (_DLL)
  156. # pragma message("You are not using DLL C run time library. " \
  157. "You must call log4cplus::initialize() once before " \
  158. "you use any other log4cplus API.")
  159. # endif
  160. #endif
  161. #endif // _WIN32
  162. #endif // LOG4CPLUS_CONFIG_WIN32_HEADER_