Hi Bruno,

Bruno Haible via Gnulib discussion list <bug-gnulib@gnu.org> writes:

> /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.

Thanks.

I noticed similar warnings caused by the return type when building gzip
from master (gzip is not localized). On a Fedora 42 system with
GNULIB_SRCDIR set so the latest Gnulib commit is used instead of
creating a git submodule:

    $ /usr/lib/libc.so.6  | sed 1q
    GNU C Library (GNU libc) stable release version 2.41.
    $ gcc --version | sed 1q
    gcc (GCC) 15.1.1 20250521 (Red Hat 15.1.1-2)
    $ echo $GNULIB_SRCDIR
    /home/collin/.local/src/gnulib
    $ ./bootstrap && ./configure && make V=1
    [...]
    gcc -DHAVE_CONFIG_H -I.    -fstrict-flex-arrays -Wall -Warith-conversion 
-Wbad-function-cast -Wcast-align=strict -Wdate-time -Wdouble-promotion 
-Wduplicated-cond -Wextra -Wformat-signedness -Wflex-array-member-not-at-end 
-Winit-self -Winvalid-pch -Wmissing-declarations -Wmissing-include-dirs 
-Wmissing-variable-declarations -Wnull-dereference -Wopenmp-simd 
-Woverlength-strings -Wpacked -Wpointer-arith -Wstrict-flex-arrays 
-Wstrict-prototypes -Wsuggest-attribute=cold -Wsuggest-attribute=const 
-Wsuggest-attribute=format -Wsuggest-attribute=malloc 
-Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-final-methods 
-Wsuggest-final-types -Wsync-nand -Wtrampolines -Wunknown-pragmas 
-Wvariadic-macros -Wvector-operation-performance -Wvla -Wwrite-strings 
-Warray-bounds=2 -Wattribute-alias=2 -Wbidi-chars=any,ucn -Wformat-overflow=2 
-Wformat=2 -Wimplicit-fallthrough=5 -Wshift-overflow=2 -Wuse-after-free=3 
-Wunused-const-variable=2 -Wvla-larger-than=4031 -Wno-sign-compare 
-Wno-type-limits -Wno-unused-parameter -Wsuggest-attribute=const 
-Wsuggest-attribute=noreturn -Wno-format-nonliteral -Wsuggest-attribute=pure 
-Wno-logical-op -fdiagnostics-show-option -funit-at-a-time -Werror 
-Wno-cast-qual -Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef 
-Wno-unused-function -Wno-unused-parameter -Wno-float-conversion 
-Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits 
-Wno-unused-const-variable -Wno-unsuffixed-float-constants -Wno-error -g -O2 
-MT libgzip_a-xalloc-die.o -MD -MP -MF .deps/libgzip_a-xalloc-die.Tpo -c -o 
libgzip_a-xalloc-die.o `test -f 'xalloc-die.c' || echo './'`xalloc-die.c
    In file included from xalloc-die.c:28:
    gettext.h:74:1: warning: mismatch in return type of built-in function 
'gettext'; expected 'char *' [-Wbuiltin-declaration-mismatch]
       74 | gettext (const char *msgid)
          | ^~~~~~~
    gettext.h:83:1: warning: mismatch in return type of built-in function 
'dgettext'; expected 'char *' [-Wbuiltin-declaration-mismatch]
       83 | dgettext (const char *domain, const char *msgid)
          | ^~~~~~~~
    gettext.h:93:1: warning: mismatch in return type of built-in function 
'dcgettext'; expected 'char *' [-Wbuiltin-declaration-mismatch]
       93 | dcgettext (const char *domain, const char *msgid, int category)
          | ^~~~~~~~~
    mv -f .deps/libgzip_a-xalloc-die.Tpo .deps/libgzip_a-xalloc-die.Po
    [...]

Sorry I couldn't find an easier gnulib-tool recipe to replicate...

I think I remember you mentioning that gettext will be standardized to
return 'const char *' in the future. If so, I expect glibc and others to
change this in the future. Wouldn't it be safer to do something like
ICONV_CONST?

Collin

Reply via email to