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

Re: [PATCH] Fixed format specifier width mismatch


On (22/12/15 04:28), Joseph Ates wrote:
>On Mon, 21 Dec 2015, Lukas Slebodnik wrote:
>> On (20/12/15 16:29), Joseph Ates wrote:
>> >+#  define LargestIntegralTypePrintfFormatDecimal "%I64u"
>> character "%" is usually not part of format string macros
>> 
>> @see standard header file inttypes.h
>> (or manual page)
>
>The patch attempts to match the current format specifiers for the macro 
>LargestIntegralTypePrintfFormat which cannot be represented without the 
>"%" character on WIN32. For WIN32, LargestIntegralTypePrintfFormat is 
You are right. I only read the patch. I didn't notice this.
So it would be better to be consistent.

Patch looks good to me.

>defined as:
>
>#  define LargestIntegralTypePrintfFormat "0x%I64x"
>
>However on other platforms it is defined as:
>
>#  if __WORDSIZE == 64
>#   define LargestIntegralTypePrintfFormat "%#lx"
>#  else
>#   define LargestIntegralTypePrintfFormat "%#llx"
>#  endif
>
>This seems inconsistent as the permanent "0x" prefix used on WIN32 
>allows for representing zero values with a hexadecimal prefix (e.g. 
>"0x0") but the "#" flag represents the zero without any prefix (e.g. 
>"0").
>

BTW  PRIu64 should be used for 64 bit unsined integer.
Could you tell us which platform is problematic?
(I guess windows :-)
>On some platforms PRIu64 is not necessarily the width of the
>LargestIntegralType. A new decimal format specifier for
>LargestIntegralType was added and replaces the invocations of PRIu64.

LS