Skip to content

Commit a1b9319

Browse files
authored
Merge pull request #872 from compnerd/static
dispatch: split `DISPATCH_EXPORT` and prepare for static linking
2 parents 8b61977 + e1fb209 commit a1b9319

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

dispatch/base.h

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,24 +178,32 @@
178178
#endif
179179
#endif
180180

181-
#if defined(_WIN32)
182-
#if defined(__DISPATCH_BUILDING_DISPATCH__)
183-
#if defined(__cplusplus)
184-
#define DISPATCH_EXPORT extern "C" __declspec(dllexport)
185-
#else
186-
#define DISPATCH_EXPORT extern __declspec(dllexport)
187-
#endif
188-
#else
189-
#if defined(__cplusplus)
190-
#define DISPATCH_EXPORT extern "C" __declspec(dllimport)
191-
#else
192-
#define DISPATCH_EXPORT extern __declspec(dllimport)
193-
#endif
181+
#ifndef DISPATCH_EXTERN
182+
# if defined(__cplusplus)
183+
# define DISPATCH_EXTERN extern "C"
184+
# else
185+
# define DISPATCH_EXTERN extern
186+
# endif
194187
#endif
195-
#elif __GNUC__
196-
#define DISPATCH_EXPORT extern __attribute__((visibility("default")))
188+
189+
#if defined(dispatch_STATIC)
190+
# if __GNUC__
191+
# define DISPATCH_EXPORT DISPATCH_EXTERN __attribute__((__visibility__("hidden")))
192+
# else
193+
# define DISPATCH_EXPORT DISPATCH_EXTERN
194+
# endif
197195
#else
198-
#define DISPATCH_EXPORT extern
196+
# if defined(_WIN32)
197+
# if defined(dispatch_EXPORT) || defined(__DISPATCH_BUILDING_DISPATCH__)
198+
# define DISPATCH_EXPORT DISPATCH_EXTERN __declspec(dllexport)
199+
# else
200+
# define DISPATCH_EXPORT DISPATCH_EXTERN __declspec(dllimport)
201+
# endif
202+
# elif __GNUC__
203+
# define DISPATCH_EXPORT DISPATCH_EXTERN __attribute__((__visibility__("default")))
204+
# else
205+
# define DISPATCH_EXPORT DISPATCH_EXTERN
206+
# endif
199207
#endif
200208

201209
#if __GNUC__

0 commit comments

Comments
 (0)