+2022-07-03 Bruno Haible <bruno@clisp.org>
+
+ lib-symbol-visibility: Improve documentation.
+ Reported by Vivien Kraus <vivien@planete-kraus.eu> in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2022-06/msg00093.html>.
+ * doc/lib-symbol-visibility.texi: List the platforms. Extend the
+ LIBFOO_DLL_EXPORTED to work also with mingw and also with
+ --disable-shared.
+
2022-07-03 Bruno Haible <bruno@clisp.org>
supersede: Support the file name "/dev/null" on native Windows.
as a substituted variable: @@HAVE_VISIBILITY@@. Its value is 1 when symbol
visibility control is supported, and 0 otherwise.
+As of 2022, symbol visibility control is supported on
+@itemize @bullet
+@item
+ELF platforms (glibc, Linux, *BSD, Solaris) with GCC or clang,
+@item
+macOS,
+@item
+AIX with gcc or xlclang.
+@end itemize
+@noindent
+It is not supprted on
+@itemize @bullet
+@item
+Other compilers on ELF platforms or AIX,
+@item
+Windows.
+@end itemize
+
To use this module in a library, say libfoo, you will do these steps:
@enumerate
@item
Define a macro specific to your library like this.
@smallexample
-#if BUILDING_LIBFOO && HAVE_VISIBILITY
+#if HAVE_VISIBILITY && BUILDING_LIBFOO
#define LIBFOO_DLL_EXPORTED __attribute__((__visibility__("default")))
#else
#define LIBFOO_DLL_EXPORTED
Note about other compilers: MSVC support can be added easily, by extending
the definition of the macro mentioned above, to something like this:
@smallexample
-#if BUILDING_LIBFOO && HAVE_VISIBILITY
+#if HAVE_VISIBILITY && BUILDING_LIBFOO
#define LIBFOO_DLL_EXPORTED __attribute__((__visibility__("default")))
-#elif BUILDING_LIBFOO && defined _MSC_VER
+#elif (defined _WIN32 && !defined __CYGWIN__) && BUILDING_SHARED && BUILDING_LIBFOO
#define LIBFOO_DLL_EXPORTED __declspec(dllexport)
-#elif defined _MSC_VER
+#elif (defined _WIN32 && !defined __CYGWIN__) && BUILDING_SHARED
#define LIBFOO_DLL_EXPORTED __declspec(dllimport)
#else
#define LIBFOO_DLL_EXPORTED
#endif
@end smallexample
+@noindent
+Here @code{BUILDING_SHARED} is a C macro that you have to define. It
+ought to evaluate to 1 in a build configured with @samp{--enable-shared},
+or to 0 in a build configured with @samp{--disable-shared}.