bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gettext 0.22 fails to build with mingw gcc


From: Bruno Haible
Subject: Re: gettext 0.22 fails to build with mingw gcc
Date: Thu, 29 Jun 2023 14:31:27 +0200

Hi,

Biswapriyo Nath wrote:
> * gcc version 13.1.0
> * Thread model: posix
> * Target: x86_64-w64-mingw32
> * Source tarball: https://ftp.gnu.org/pub/gnu/gettext/gettext-0.22.tar.gz
> * Configure options:
> https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-gettext/PKGBUILD
> * Extra patches:
> https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-gettext
> * Compiler error:
> 
> gettext-runtime/libasprintf/lib-asprintf.c:23:18: error: static
> declaration of 'libasprintf_asprintf' follows non-static declaration
>    23 | #define asprintf libasprintf_asprintf
>       |                  ^~~~~~~~~~~~~~~~~~~~
> gettext-runtime/libasprintf/lib-asprintf.c:23:18: note: previous
> declaration of 'libasprintf_asprintf' with type 'int(char **, const
> char *, ...)'
>    23 | #define asprintf libasprintf_asprintf
>       |                  ^~~~~~~~~~~~~~~~~~~~
> gettext-runtime/libasprintf/vasprintf.h:44:12: note: in expansion of
> macro 'asprintf'
>    44 | extern int asprintf (char **result, const char *format, ...)
>       |            ^~~~~~~~
> 
> The same error happen with vasprintf also. How can I fix or
> troubleshoot this issue?

1) The compiler that you are using is not very helpful: it prints the location
of the non-static declaration (gettext-runtime/libasprintf/vasprintf.h:44)
but not the location of the 'static' declaration.

The workaround in this situation is — as usual — to look at the preprocessed
output for that compilation unit:
  1. run "make -n lib-asprintf.o"
  2. from that command, remove the -c and -o option and instead add "-E -dD".
  3. run that command, redirecting its output to a file.

In that output, look for a static declaration of libasprintf_asprintf.
I don't see such a declaration in the libasprintf sources. So maybe it comes
from mingw's <stdio.h>?

2) GNU gettext uses a mechanism to deactivate this <stdio.h> quirk and thus
avoid the compilation error. Namely, in gettext-runtime/libasprintf/Makefile.am
it adds -D__USE_MINGW_ANSI_STDIO=0 to the compilation options.

In config.h we have this declaration:

/* Use GNU style printf and scanf.  */
#ifndef __USE_MINGW_ANSI_STDIO
# define __USE_MINGW_ANSI_STDIO 1
#endif

but it has no effect since the value of __USE_MINGW_ANSI_STDIO is initially 0.

3) Now, your turn to find out why it works for me (in the Cygwin dev
environment, as explained in the INSTALL.windows file) but not for you.


Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]