[FFmpeg-devel] uint32_t arg and %X conversion specifier
Thu Jan 15 15:49:03 CET 2009
M?ns Rullg?rd wrote:
> Marc Mason wrote:
>> I see two ways to fix the following (very minor) warning.
>> avidec.c:428: warning: format '%X' expects type 'unsigned int', but
>> argument 4 has type 'uint32_t'
>> 1) cast the arg to unsigned long
>> drawback : on platforms where long are 64-bits wide, this will push 4
>> useless ( == 0 ) octets
> One could cast to unsigned int too.
I don't think so.
Consider a platform where
sizeof(unsigned int) = 16 bits
sizeof(unsigned long) = 32 bits
On such a platform, uint32_t would probably be typedef'ed to unsigned
long. Casting to unsigned int would truncate the value.
While long and unsigned long must be at least 32-bits wide by design.
>> 2) use the appropriate macro for the conversion specifier
>> drawback : C99 specific ??
> We already use those in many places. The avidec maintainer can decide
> what to do.
FWIW, I prefer the second solution (I spent too much time with the
"casts are baaad, mmmkay" crowd).
More information about the ffmpeg-devel