Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: [XS] : "snprintf" portability options

by syphilis (Archbishop)
on Sep 16, 2024 at 00:53 UTC ( [id://11161747]=note: print w/replies, xml ) Need Help??


in reply to Re: [XS] : "snprintf" portability options
in thread [XS] : "snprintf" portability options

This is why win32/GNNUmakefile adds -Wno-format after -Wall and -Wextra

And the Cpanel-JSON-XS-4.38 Makefile.PL then oh-so-thoughtfully re-introduces the issue by appending "-Wall -Wextra -W" .... I'll submit a PR for that Makefile.PL, along with a PR to XS.xs that allows Cpanel::JSON::XS to build on Windows quadmath perls (and also silences some other warnings).

Thanks tonyc - I remember that issue, now.
At one stage yesterday it crossed my mind that I don't usually encounter [-Wformat=] warnings ... but I still failed to make the connection :-(

Cheers,
Rob

Replies are listed 'Best First'.
Re^3: [XS] : "snprintf" portability options
by ikegami (Patriarch) on Sep 16, 2024 at 10:27 UTC

    oh-so-thoughtfully re-introduces the issue

    No it doesn't. The issue is there with or without the -Wformat. Your sarcasm is misplaced since the warning isn't spurious. The issue is that the wrong format is being used. This is a real error that needs fixing.

      The warning is spurious, %I64u is valid on Windows. Unfortunately with the macro the full text of the format is hidden so all you have is the misleading "%u" from the base message:

      C:\Users\Tony\dev\perl\git>gcc -Wformat -oint64.exe int64.c int64.c: In function 'main': int64.c:6:15: warning: format '%u' expects argument of type 'unsigned +int', but argument 2 has type 'long long unsigned int' [-Wformat=] 6 | printf("%I64u\n", x); | ~~~~^ ~ | | | | | long long unsigned int | unsigned int | %I64llu C:\Users\Tony\dev\perl\git>type int64.c #include <stdio.h> unsigned long long x = 0; int main() { printf("%I64u\n", x); }

      If it is a bug, it's a bug in perl, since that's where the macro OP is using comes from.

      I've considered changing the Win32 config in perl to use "%llu"/"%lld" instead, but testing against the older versions of MSVCRT in older Windows that we theoretically support is difficult.

        If it is a bug, it's a bug in perl

        Don't you mean a bug in gcc? gcc knows it is building for the MS libc, so it should accept the patterns known to work for that libc.

        Bad test. You just repeated what was already said. But replacing 0 with 9223372036854775808ull does make your point.

        So the compiler is wrong about the expected format. wow!

        And thankfully, it still provides the expected format.

        If it is a bug, it's a bug in perl

        It's a bug in gcc. The format expects a unsigned long long, but it claims it expects an unsigned.

      jdporter or someone - when I saw the reply in my "chatterbox", it didn't link to my article, but to a node "XS" (a Super Search link). I think that might be a bug?
        jdporter or someone . . .

        I can see now that we need a "mentions" notification feature. :-/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11161747]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2025-11-07 04:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (65 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.