log4cplus  2.1.0
win32.h
Go to the documentation of this file.
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 
24 #ifndef LOG4CPLUS_CONFIG_WIN32_HEADER_
25 #define LOG4CPLUS_CONFIG_WIN32_HEADER_
26 
27 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
28 #pragma once
29 #endif
30 
31 #if defined (__MINGW32__) || defined (__MINGW64__)
32 # include <_mingw.h>
33 #endif
34 
35 #ifdef _WIN32
36 
37 #if (defined (_MSC_VER) && _MSC_VER > 1400) \
38  || (defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 3)
39 # define LOG4CPLUS_HAVE_INTRIN_H
40 #endif
41 
42 // Time related functions and headers.
43 #define LOG4CPLUS_HAVE_TIME_H
44 #define LOG4CPLUS_HAVE_SYS_TIMEB_H
45 #define LOG4CPLUS_HAVE_FTIME
46 #if defined (_MSC_VER) || defined (__BORLANDC__)
47 #define LOG4CPLUS_HAVE_GMTIME_S
48 #endif
49 
50 // Use Winsock on Windows.
51 #define LOG4CPLUS_USE_WINSOCK
52 
53 // Enable Win32DebugAppender
54 #define LOG4CPLUS_HAVE_OUTPUTDEBUGSTRING
55 
56 // Enable Win32ConsoleAppender.
57 #define LOG4CPLUS_HAVE_WIN32_CONSOLE
58 
59 #define LOG4CPLUS_HAVE_SYS_TYPES_H
60 #define LOG4CPLUS_HAVE_SYS_LOCKING_H
61 #define LOG4CPLUS_HAVE_FCNTL_H
62 #define LOG4CPLUS_HAVE_IO_H
63 #define LOG4CPLUS_HAVE_STDIO_H
64 #define LOG4CPLUS_HAVE_WCHAR_H
65 #define LOG4CPLUS_HAVE_STDARG_H
66 #define LOG4CPLUS_HAVE_STDLIB_H
67 #define LOG4CPLUS_HAVE_ERRNO_H
68 #define LOG4CPLUS_HAVE_SYS_STAT_H
69 #define LOG4CPLUS_HAVE_TIME_H
70 #define LOG4CPLUS_HAVE_STDLIB_H
71 #define LOG4CPLUS_HAVE_DIRECT_H
72 
73 // MSVC has both and so does MinGW.
74 #define LOG4CPLUS_HAVE_VSNPRINTF
75 #define LOG4CPLUS_HAVE__VSNPRINTF
76 #define LOG4CPLUS_HAVE__VSNWPRINTF
77 
78 // Limit the use of foo_s() functions to builds using Visual Studio
79 // 2005 and its run time library. In MinGW land, limit the foo_s()
80 // functions to MinGw-w64 toolchain and __MSVCRT_VERSION__ >= 0x0900.
81 #if (defined (_MSC_VER) && _MSC_VER >= 1400) \
82  || (defined (__MSVCRT_VERSION__) && __MSVCRT_VERSION__ >= 0x0900 \
83  && defined (__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 2)
84 // MS secure versions of vprintf().
85 # define LOG4CPLUS_HAVE_VSPRINTF_S
86 # define LOG4CPLUS_HAVE_VSWPRINTF_S
87 
88 // MS secure versions of vfprintf().
89 # define LOG4CPLUS_HAVE_VFPRINTF_S
90 # define LOG4CPLUS_HAVE_VFWPRINTF_S
91 
92 // MS secure versions of vsnprintf().
93 # define LOG4CPLUS_HAVE_VSNPRINTF_S
94 # define LOG4CPLUS_HAVE__VSNPRINTF_S
95 # define LOG4CPLUS_HAVE__VSNWPRINTF_S
96 
97 // MS secure version of _tsopen().
98 # define LOG4CPLUS_HAVE__TSOPEN_S
99 #endif
100 
101 #if defined (_MSC_VER) && _MSC_VER >= 1400
102 // MS printf-like functions supporting positional parameters.
103 # define LOG4CPLUS_HAVE__VSPRINTF_P
104 # define LOG4CPLUS_HAVE__VSWPRINTF_P
105 #endif
106 
107 #if defined (_MSC_VER)
108 # define LOG4CPLUS_HAVE_LOCALTIME_S
109 #endif
110 
111 #define LOG4CPLUS_HAVE__TSOPEN
112 
113 #define LOG4CPLUS_DLLMAIN_HINSTANCE HINSTANCE
114 #define LOG4CPLUS_HAVE_NT_EVENT_LOG
115 
116 // log4cplus_EXPORTS is used by the CMake build system. DLL_EXPORT is
117 // used by the autotools build system.
118 #if (defined (log4cplus_EXPORTS) || defined (log4cplusU_EXPORTS) \
119  || (defined (DLL_EXPORT) && defined (INSIDE_LOG4CPLUS))) \
120  && ! defined (LOG4CPLUS_STATIC)
121 # undef LOG4CPLUS_BUILD_DLL
122 # define LOG4CPLUS_BUILD_DLL
123 #endif
124 
125 #if ! defined (LOG4CPLUS_BUILD_DLL)
126 # undef LOG4CPLUS_STATIC
127 # define LOG4CPLUS_STATIC
128 #endif
129 
130 #if defined (LOG4CPLUS_STATIC) && defined (LOG4CPLUS_BUILD_DLL)
131 # error LOG4CPLUS_STATIC and LOG4CPLUS_BUILD_DLL cannot be defined both.
132 #endif
133 
134 #if defined (LOG4CPLUS_BUILD_DLL)
135 # if defined (INSIDE_LOG4CPLUS)
136 # define LOG4CPLUS_EXPORT __declspec(dllexport)
137 # else
138 # define LOG4CPLUS_EXPORT __declspec(dllimport)
139 # endif
140 #else
141 # define LOG4CPLUS_EXPORT
142 #endif
143 
144 #ifndef LOG4CPLUS_SINGLE_THREADED
145 # define LOG4CPLUS_USE_WIN32_THREADS
146 #endif
147 
148 #if defined(_MSC_VER)
149  // Warning about: identifier was truncated to '255' characters in the debug information
150 # pragma warning( disable : 4786 )
151  // Warning about: <type1> needs to have dll-interface to be used by clients of class <type2>
152 # pragma warning( disable : 4251 )
153 
154 # define LOG4CPLUS_INLINES_ARE_EXPORTED
155 
156 # if _MSC_VER >= 1400
157 # define LOG4CPLUS_WORKING_LOCALE
158 # define LOG4CPLUS_HAVE_FUNCTION_MACRO
159 # define LOG4CPLUS_HAVE_FUNCSIG_MACRO
160 # define LOG4CPLUS_ATTRIBUTE_NORETURN __declspec(noreturn)
161 # endif
162 #endif
163 
164 #if defined (__GNUC__)
165 # undef LOG4CPLUS_INLINES_ARE_EXPORTED
166 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
167 # define LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO
168 # define LOG4CPLUS_HAVE_FUNC_SYMBOL
169 # endif
170 // This has worked for some versions of MinGW with GCC 4.7+ but it
171 // appears to be broken again in 4.8.x. Thus, we disable this for GCC
172 // completely forever.
173 //
174 //# define LOG4CPLUS_INLINES_ARE_EXPORTED
175 # define LOG4CPLUS_HAVE_FUNCTION_MACRO
176 # if defined (__MINGW32__)
177 # define LOG4CPLUS_WORKING_C_LOCALE
178 # endif
179 #endif
180 
181 #if defined (__BORLANDC__) && __BORLANDC__ >= 0x0650
182 # define LOG4CPLUS_HAVE_FUNCTION_MACRO
183 #endif // __BORLANDC__
184 
185 #if ! defined (LOG4CPLUS_DISABLE_DLL_RUNTIME_WARNING)
186 # if defined (LOG4CPLUS_STATIC) && defined (_MSC_VER) && ! defined (_DLL)
187 # pragma message("You are not using DLL C run time library. " \
188  "You must call log4cplus::initialize() once before " \
189  "you use any other log4cplus API.")
190 # endif
191 #endif
192 
193 #endif // _WIN32
194 #endif // LOG4CPLUS_CONFIG_WIN32_HEADER_