@@ -130,25 +130,44 @@ set, we ensure here that it has no effect. */
130
130
#define PCRE2_CALL_CONVENTION
131
131
#endif
132
132
133
- /* When an application links to a PCRE2 DLL in Windows, the symbols that are
134
- imported have to be identified as such. When building PCRE2, the appropriate
135
- export settings are needed, and are set in pcre2posix.c before including this
136
- file. */
137
-
138
- #if defined(_WIN32 ) && !defined(PCRE2_STATIC ) && !defined(PCRE2POSIX_EXP_DECL )
139
- # define PCRE2POSIX_EXP_DECL extern __declspec(dllimport)
140
- # define PCRE2POSIX_EXP_DEFN __declspec(dllimport)
141
- #endif
142
-
143
- /* By default, we use the standard "extern" declarations. */
133
+ /* When compiling a DLL for Windows, the exported symbols have to be declared
134
+ using some MS magic. I found some useful information on this web page:
135
+ http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the
136
+ information there, using __declspec(dllexport) without "extern" we have a
137
+ definition; with "extern" we have a declaration.
138
+ We use:
139
+
140
+ PCRE2_EXP_DECL for declarations
141
+ PCRE2_EXP_DEFN for definitions
142
+
143
+ The reason for wrapping this in #ifndef PCRE2POSIX_EXP_DECL is so that
144
+ pcre2test, which is an application, but needs to import this file in order to
145
+ "peek" at internals, can #include pcre2posix.h first to get an application's-eye
146
+ view.
147
+
148
+ In principle, people compiling for non-Windows, non-Unix-like (i.e. uncommon,
149
+ special-purpose environments) might want to stick other stuff in front of
150
+ exported symbols. That's why, in the non-Windows case, we set
151
+ PCRE2POSIX_EXP_DEFN only if it is not already set. */
144
152
145
153
#ifndef PCRE2POSIX_EXP_DECL
146
- # ifdef __cplusplus
147
- # define PCRE2POSIX_EXP_DECL extern "C"
148
- # define PCRE2POSIX_EXP_DEFN extern "C"
154
+ # ifdef _WIN32
155
+ # ifndef PCRE2_STATIC
156
+ # define PCRE2POSIX_EXP_DECL extern __declspec(dllexport)
157
+ # define PCRE2POSIX_EXP_DEFN __declspec(dllexport)
158
+ # else
159
+ # define PCRE2POSIX_EXP_DECL extern
160
+ # define PCRE2POSIX_EXP_DEFN
161
+ # endif
149
162
# else
150
- # define PCRE2POSIX_EXP_DECL extern
151
- # define PCRE2POSIX_EXP_DEFN extern
163
+ # ifdef __cplusplus
164
+ # define PCRE2POSIX_EXP_DECL extern "C"
165
+ # else
166
+ # define PCRE2POSIX_EXP_DECL extern
167
+ # endif
168
+ # ifndef PCRE2POSIX_EXP_DEFN
169
+ # define PCRE2POSIX_EXP_DEFN PCRE2POSIX_EXP_DECL
170
+ # endif
152
171
# endif
153
172
#endif
154
173
0 commit comments