]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
intl: Don't export symbols from static MSVC .obj files.
authorBruno Haible <bruno@clisp.org>
Wed, 6 Sep 2023 18:59:03 +0000 (20:59 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 19 Sep 2023 02:10:12 +0000 (04:10 +0200)
* gettext-runtime/intl/intl-compat.c (DLL_EXPORTED): Set to empty on MSVC when
DLL_EXPORT is not defined.
* gettext-runtime/intl/printf.c (DLL_EXPORTED): Likewise.
* gettext-runtime/intl/setlocale.c (DLL_EXPORTED): Likewise.

gettext-runtime/intl/intl-compat.c
gettext-runtime/intl/printf.c
gettext-runtime/intl/setlocale.c

index e2b8d6c371aea8ef65200e8b18e29ed4658ea212..d141e0453a4936dcefab11a73f214f372a08f734 100644 (file)
@@ -1,6 +1,6 @@
 /* intl-compat.c - Stub functions to call gettext functions from GNU gettext
    Library.
-   Copyright (C) 1995, 2000-2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2000-2003, 2005, 2023 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
 #if HAVE_VISIBILITY && BUILDING_DLL
 # define DLL_EXPORTED __attribute__((__visibility__("default")))
 #elif defined _MSC_VER && BUILDING_DLL
-# define DLL_EXPORTED __declspec(dllexport)
+/* When building with MSVC, exporting a symbol means that the object file
+   contains a "linker directive" of the form /EXPORT:symbol.  This can be
+   inspected through the "objdump -s --section=.drectve FILE" or
+   "dumpbin /directives FILE" commands.
+   The symbols from this file should be exported if and only if the object
+   file gets included in a DLL.  Libtool, on Windows platforms, defines
+   the C macro DLL_EXPORT (together with PIC) when compiling for a DLL
+   and does not define it when compiling an object file meant to be linked
+   statically into some executable.  */
+# if defined DLL_EXPORT
+#  define DLL_EXPORTED __declspec(dllexport)
+# else
+#  define DLL_EXPORTED
+# endif
 #else
 # define DLL_EXPORTED
 #endif
index de2d58470dd6fc6b1b2d204cc4a91c5c4724b89f..836cc07329417fd091384ed8f47de3e83e20c719 100644 (file)
@@ -64,7 +64,20 @@ char *alloca ();
 #if HAVE_VISIBILITY && BUILDING_DLL
 # define DLL_EXPORTED __attribute__((__visibility__("default")))
 #elif defined _MSC_VER && BUILDING_DLL
-# define DLL_EXPORTED __declspec(dllexport)
+/* When building with MSVC, exporting a symbol means that the object file
+   contains a "linker directive" of the form /EXPORT:symbol.  This can be
+   inspected through the "objdump -s --section=.drectve FILE" or
+   "dumpbin /directives FILE" commands.
+   The symbols from this file should be exported if and only if the object
+   file gets included in a DLL.  Libtool, on Windows platforms, defines
+   the C macro DLL_EXPORT (together with PIC) when compiling for a DLL
+   and does not define it when compiling an object file meant to be linked
+   statically into some executable.  */
+# if defined DLL_EXPORT
+#  define DLL_EXPORTED __declspec(dllexport)
+# else
+#  define DLL_EXPORTED
+# endif
 #else
 # define DLL_EXPORTED
 #endif
index d18e1f39dd0a56576e6a05430093ee67970c4bd5..ea671833e2ed06fab07117a7cd039f357ed3ecd1 100644 (file)
@@ -1,5 +1,5 @@
 /* setlocale() function that respects the locale chosen by the user.
-   Copyright (C) 2009, 2011, 2013, 2018-2019, 2022 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2011, 2013, 2018-2019, 2022-2023 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2009.
 
    This program is free software: you can redistribute it and/or modify
 #if HAVE_VISIBILITY && BUILDING_DLL
 # define DLL_EXPORTED __attribute__((__visibility__("default")))
 #elif defined _MSC_VER && BUILDING_DLL
-# define DLL_EXPORTED __declspec(dllexport)
+/* When building with MSVC, exporting a symbol means that the object file
+   contains a "linker directive" of the form /EXPORT:symbol.  This can be
+   inspected through the "objdump -s --section=.drectve FILE" or
+   "dumpbin /directives FILE" commands.
+   The symbols from this file should be exported if and only if the object
+   file gets included in a DLL.  Libtool, on Windows platforms, defines
+   the C macro DLL_EXPORT (together with PIC) when compiling for a DLL
+   and does not define it when compiling an object file meant to be linked
+   statically into some executable.  */
+# if defined DLL_EXPORT
+#  define DLL_EXPORTED __declspec(dllexport)
+# else
+#  define DLL_EXPORTED
+# endif
 #else
 # define DLL_EXPORTED
 #endif