[PATCH v2 16/16] lib: Use HAVE_LIBINTL_H to guard #include <libintl.h>

Yonggang Luo luoyonggang@gmail.com
Sat Dec 17 16:52:13 GMT 2022


MSVC doesn't have libintl.h, so use macro to guard it.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 configure.ac    | 2 ++
 lib/eu-config.h | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/configure.ac b/configure.ac
index b84623fe..aea12be3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -441,6 +441,8 @@ AC_CHECK_FUNCS([process_vm_readv mremap])
 AS_IF([test "x$ac_cv_func_mremap" = "xno"],
       [AC_MSG_WARN([elf_update needs mremap to support ELF_C_RDWR_MMAP])])
 
+AC_CHECK_HEADERS([libintl.h])
+
 AC_CHECK_HEADERS([error.h])
 AC_CHECK_HEADERS([err.h])
 
diff --git a/lib/eu-config.h b/lib/eu-config.h
index 78a5c4fe..72b7793e 100644
--- a/lib/eu-config.h
+++ b/lib/eu-config.h
@@ -52,10 +52,17 @@
 # define rwlock_unlock(lock) ((void) (lock))
 #endif	/* USE_LOCKS */
 
+#if defined(HAVE_LIBINTL_H)
 #include <libintl.h>
+#endif
+
 /* gettext helper macros.  */
 #define N_(Str) Str
+#if defined(HAVE_LIBINTL_H)
 #define _(Str) dgettext ("elfutils", Str)
+#else
+#define _(Str) N_(Str)
+#endif
 
 /* Compiler-specific definitions.  */
 #define strong_alias(name, aliasname) \
-- 
2.36.1.windows.1



More information about the Elfutils-devel mailing list