Am 06.09.2016 um 19:29 schrieb David Grayson:
> Having only thought about this for a few minutes, I am guessing that
> you would need to use the Microsoft-style printf modifier and also use
> a GCC pragma to suppress the warning:
>
> https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html
>
> --David
>
> On Tue, Sep 6, 2016 at 9:06 AM, Jeroen Ooms <[email protected]> wrote:
>> How to print a 'long long int' so that it compiles
>> without -pedantic warnings? I tried:
>>
>> long long int number
>> char i[32];
>> sprintf(i, "%lld", number);
>>
>> But this gives: warning: unknown conversion type character 'l' in format. I
>> also tried:
>>
>> sprintf(i, "%I64d", number);
>>
>> But this gives: warning: ISO C does not support the 'I64' ms_printf length
>> modifier.
>>
>> It's a bit of a silly question but my repository maintainers insist that
>> code compiles without any pedantic warnings.
>> ----------------------------------------------------------------------------
Your repository maintainer has good reasons for such a request.
Of course you could suppress warnings with pragma statements,
but that would not be a good idea.
I suggest using the ANSI format specifiers ("%lld" is correct in
your example) and telling the compiler that you do so. Add
-D__USE_MINGW_ANSI_STDIO=1 to the compiler options
(or define that macro before including any header files).
If you use ANSI format specifiers, those code lines will also
work on non-Windows platforms - maybe this is also important
for you.
Kind regards,
Stefan
------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public