I wrote: > 2025-05-28 Bruno Haible <br...@clisp.org> > > gettext-h: Avoid gcc -Wformat-security warnings with --disable-nls.
Oops, this causes compilation errors on Solaris 11: In file included from ../../gltests/xalloc-die.c:28: ../../gltests/gettext.h:69:1: error: conflicting types for ‘gettext’; have ‘const char *(const char *)’ 69 | gettext (const char *msgid) | ^~~~~~~ In file included from /usr/include/locale.h:12, from ./locale.h:41, from ../../gltests/gettext.h:49: /usr/include/libintl.h:50:14: note: previous declaration of ‘gettext’ with type ‘char *(const char *)’ 50 | extern char *gettext(const char *); | ^~~~~~~ ../../gltests/gettext.h:75:1: error: conflicting types for ‘dgettext’; have ‘const char *(const char *, const char *)’ 75 | dgettext (const char *domain, const char *msgid) | ^~~~~~~~ /usr/include/libintl.h:52:14: note: previous declaration of ‘dgettext’ with type ‘char *(const char *, const char *)’ 52 | extern char *dgettext(const char *, const char *); | ^~~~~~~~ ../../gltests/gettext.h:82:1: error: conflicting types for ‘dcgettext’; have ‘const char *(const char *, const char *, int)’ 82 | dcgettext (const char *domain, const char *msgid, int category) | ^~~~~~~~~ /usr/include/libintl.h:54:14: note: previous declaration of ‘dcgettext’ with type ‘char *(const char *, const char *, int)’ 54 | extern char *dcgettext(const char *, const char *, int); | ^~~~~~~~~ *** Error code 1 This patch fixes it. 2025-05-31 Bruno Haible <br...@clisp.org> gettext-h: Fix compilation error on Solaris 11 (regr. 2025-05-28). * lib/gettext.h (gettext, dgettext, dcgettext): On Solaris, use 'char *' as return type. diff --git a/lib/gettext.h b/lib/gettext.h index bb3d9755de..7a7f02e3ee 100644 --- a/lib/gettext.h +++ b/lib/gettext.h @@ -64,21 +64,32 @@ /* Use inline functions, to avoid warnings warning: format not a string literal and no format arguments that don't occur with enabled NLS. */ +/* The return type 'const char *' serves the purpose of producing warnings + for invalid uses of the value returned from these functions. */ __attribute__ ((__always_inline__, __gnu_inline__)) extern inline -const char * +# if !defined(__sun) +const +# endif +char * gettext (const char *msgid) { return msgid; } __attribute__ ((__always_inline__, __gnu_inline__)) extern inline -const char * +# if !defined(__sun) +const +# endif +char * dgettext (const char *domain, const char *msgid) { (void) domain; return msgid; } __attribute__ ((__always_inline__, __gnu_inline__)) extern inline -const char * +# if !defined(__sun) +const +# endif +char * dcgettext (const char *domain, const char *msgid, int category) { (void) domain;