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

I suspect you're running into gcc -Wformat not supporting the Windows specific "%I64u" format.

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

  • Comment on Re: [XS] : "snprintf" portability options

Replies are listed 'Best First'.
Re^2: [XS] : "snprintf" portability options
by syphilis (Archbishop) on Sep 16, 2024 at 00:53 UTC
    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

      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.

        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?