bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] stdio: fix probe on mingw under gcc 5.1


From: Assaf Gordon
Subject: Re: [PATCH] stdio: fix probe on mingw under gcc 5.1
Date: Tue, 26 May 2015 18:09:42 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

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



reply via email to

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