@@ -130,25 +130,46 @@ 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. The settings here override the
138
+ setting in pcre2.h (which is included below); it defines only
139
+ PCRE2POSIX_EXP_DECL, which is all that is needed for applications (they just
140
+ import the symbols). We use:
141
+
142
+ PCRE2_EXP_DECL for declarations
143
+ PCRE2_EXP_DEFN for definitions
144
+
145
+ The reason for wrapping this in #ifndef PCRE2POSIX_EXP_DECL is so that
146
+ pcre2test, which is an application, but needs to import this file in order to
147
+ "peek" at internals, can #include pcre2.h first to get an application's-eye
148
+ view.
149
+
150
+ In principle, people compiling for non-Windows, non-Unix-like (i.e. uncommon,
151
+ special-purpose environments) might want to stick other stuff in front of
152
+ exported symbols. That's why, in the non-Windows case, we set
153
+ PCRE2POSIX_EXP_DEFN only if it is not already set. */
144
154
145
155
#ifndef PCRE2POSIX_EXP_DECL
146
- # ifdef __cplusplus
147
- # define PCRE2POSIX_EXP_DECL extern "C"
148
- # define PCRE2POSIX_EXP_DEFN extern "C"
156
+ # ifdef _WIN32
157
+ # ifndef PCRE2_STATIC
158
+ # define PCRE2POSIX_EXP_DECL extern __declspec(dllexport)
159
+ # define PCRE2POSIX_EXP_DEFN __declspec(dllexport)
160
+ # else
161
+ # define PCRE2POSIX_EXP_DECL extern
162
+ # define PCRE2POSIX_EXP_DEFN
163
+ # endif
149
164
# else
150
- # define PCRE2POSIX_EXP_DECL extern
151
- # define PCRE2POSIX_EXP_DEFN extern
165
+ # ifdef __cplusplus
166
+ # define PCRE2POSIX_EXP_DECL extern "C"
167
+ # else
168
+ # define PCRE2POSIX_EXP_DECL extern
169
+ # endif
170
+ # ifndef PCRE2POSIX_EXP_DEFN
171
+ # define PCRE2POSIX_EXP_DEFN PCRE2POSIX_EXP_DECL
172
+ # endif
152
173
# endif
153
174
#endif
154
175
0 commit comments