aboutsummaryrefslogtreecommitdiffstats
path: root/ws_symbol_export.h
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-07-03 00:38:41 +0000
committerGuy Harris <guy@alum.mit.edu>2013-07-03 00:38:41 +0000
commit219c37c45aa22dce8fca3df95c6fc248b86d1382 (patch)
tree5cd8b90c2bb7528924cbea249ae4debbc33700d9 /ws_symbol_export.h
parentf4361b8e3801c4cd6b174426f25251dcbe5369e4 (diff)
OK, try having WS_DLL_PUBLIC always say "extern". If *that* doesn't
work, because it can't be used with definitions, we'll probably have to have separate macros for declarations and definitions, as I don't think MSVC likes int foo[]; in a header file but should be fine with extern int foo[]; Add some more comments while we're at it; you are in a twisty little maze of #ifdefs, all different. svn path=/trunk/; revision=50332
Diffstat (limited to 'ws_symbol_export.h')
-rw-r--r--ws_symbol_export.h50
1 files changed, 44 insertions, 6 deletions
diff --git a/ws_symbol_export.h b/ws_symbol_export.h
index 14098ffea7..e2c0e6f2fa 100644
--- a/ws_symbol_export.h
+++ b/ws_symbol_export.h
@@ -49,24 +49,62 @@
/* Originally copied from GCC Wiki at http://gcc.gnu.org/wiki/Visibility */
#if defined _WIN32 || defined __CYGWIN__
+ /* Compiling for Windows, so we use the Windows DLL declarations. */
#ifdef WS_BUILD_DLL
+ /*
+ * Building a library; for all definitions, we want dllexport, and
+ * (presumably so source from DLL and source from a program using the
+ * DLL can both include a header that declares APIs and exported data
+ * for the DLL), for declarations, either dllexport or dllimport will
+ * work (they mean the same thing for a declaration when building a DLL).
+ */
#ifdef __GNUC__
-#define WS_DLL_PUBLIC __attribute__ ((dllexport))
+ /* GCC */
+#define WS_DLL_PUBLIC __attribute__ ((dllexport)) extern
+#define WS_DLL_PUBLIC_NOEXTERN __attribute__ ((dllexport))
#else /* ! __GNUC__ */
-#define WS_DLL_PUBLIC __declspec(dllexport) /* Note: actually gcc seems to also support this syntax. */
+ /*
+ * Presumably MSVC.
+ * Note: actually gcc seems to also support this syntax.
+ */
+#define WS_DLL_PUBLIC __declspec(dllexport) extern
+#define WS_DLL_PUBLIC_NOEXTERN __declspec(dllexport)
#endif /* __GNUC__ */
#else /* WS_BUILD_DLL */
+ /*
+ * Building a program; we should only see declarations, not definitions,
+ * with WS_DLL_PUBLIC, and they all represent APIs or data imported
+ * from a DLL, so use dllimport.
+ *
+ * For functions, export shouldn't be necessary; for data, it might
+ * be necessary, e.g. if what's declared is an array whose size is
+ * not given in the declaration.
+ */
#ifdef __GNUC__
-#define WS_DLL_PUBLIC __attribute__ ((dllimport))
+ /* GCC */
+#define WS_DLL_PUBLIC __attribute__ ((dllimport)) extern
+#define WS_DLL_PUBLIC_NOEXTERN __attribute__ ((dllimport))
#elif ! (defined ENABLE_STATIC) /* ! __GNUC__ */
-#define WS_DLL_PUBLIC __declspec(dllimport) /* Note: actually gcc seems to also support this syntax. */
+ /*
+ * Presumably MSVC.
+ * Note: actually gcc seems to also support this syntax.
+ */
+#define WS_DLL_PUBLIC __declspec(dllimport) extern
+#define WS_DLL_PUBLIC_NOEXTERN __declspec(dllimport)
#else /* ! __GNUC__ && ENABLE_STATIC */
-#define WS_DLL_PUBLIC
+ /* presumably MSVC */
+#define WS_DLL_PUBLIC extern
+#define WS_DLL_PUBLIC_NOEXTERN
#endif /* __GNUC__ */
#endif /* WS_BUILD_DLL */
- #define WS_DLL_PUBLIC_NOEXTERN WS_DLL_PUBLIC
#define WS_DLL_LOCAL
#else /* defined _WIN32 || defined __CYGWIN__ */
+ /*
+ * Compiling for UN*X, where the dllimport and dllexport stuff
+ * is neither necessary nor supported; just specify the
+ * visibility if we have a compiler that claims compatibility
+ * with GCC 4 or later.
+ */
#if __GNUC__ >= 4
#define WS_DLL_PUBLIC __attribute__ ((visibility ("default"))) extern
#define WS_DLL_PUBLIC_NOEXTERN __attribute__ ((visibility ("default")))