Hello Eric,
Thanks for your quick reply and fix.
I've found one more issue which I'm not sure how to solve - interplay between
gcc/mingw/inttypes/gnulib: The format string to "error()".
In theory (if I understand correctly), printf() and error() should accept the
same format specifiers,
thus should both work with PRI.MAX.
However,
after having the PRIdMAX changed back to 'lld', using it in 'error()' causes a
warning under mingw:
To reproduce:
# Clone GNU Hello
git clone git://git.sv.gnu.org/hello.git
cd hello
# Needed as 'LC_MESSAGES' fails to compile with mingw32, not related to
this issue
sed -i '/setlocale/s/LC_MESSAGES/LC_ALL/' src/hello.c
# Use gnulib modules inttypes,stdint,extensions
sed -i '/gnulib_modules/ainttypes\nstdint\nextensions\n' bootstrap.conf
# Add #includes to the C file
sed -i '/<config\.h>/a#include <stdint.h>\n#include <inttypes.h>'
src/hello.c
# Add printf() and error() calls
sed -i '/set_program_name/ { auintmax_t a=1;
aprintf("printf-a=%"PRIdMAX"\\n",a);
aerror(0,0,_("error-a=%"PRIdMAX"\\n"),a);
}' src/hello.c
# Try to compile
./bootstrap
./configure --host=x86_64-w64-mingw32 CFLAGS="-Wall -Wextra -Wformat-security
-Wswitch-enum -Wswitch-default -Wformat-nonliteral"
make
Will give this warning about 'error()', but not about 'printf()':
x86_64-w64-mingw32-gcc -DLOCALEDIR=\"/usr/local/share/locale\"
-DHAVE_CONFIG_H -I. -Ilib -I./lib -Isrc -I./src \
-Wall -Wextra -Wformat-security -Wswitch-enum
-Wswitch-default -Wformat-nonliteral -MT \
src/hello.o -MD -MP -MF $depbase.Tpo -c -o src/hello.o
src/hello.c &&\
mv -f $depbase.Tpo $depbase.Po
src/hello.c: In function 'main':
src/hello.c:57:1: warning: unknown conversion type character 'l' in format
[-Wformat=]
error(0,0,_("error-a=%"PRIdMAX"\n"),a);
^
src/hello.c:57:1: warning: too many arguments for format
[-Wformat-extra-args]
The compiled strings are:
$ strings hello.exe | grep -- -a=
printf-a=%lld
error-a=%lld
Which brings the question: will the compiled executable work? (it compiles and
I get an 'exe' file, but don't have a way to test it ATM).
Thanks,
- assaf