[FFmpeg-devel] uint32_t arg and %X conversion specifier

Michael Niedermayer michaelni
Thu Jan 15 15:53:40 CET 2009


On Thu, Jan 15, 2009 at 03:49:03PM +0100, Marc Mason wrote:
> 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
> >> http://home.att.net/~jackklein/c/inttypes.html#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

isnt allowed by POSIX and our code wouldnt work there anyway.
Of course that doesnt mean i would be outright rejecting a patch that
made ffmpeg useable on such system (assuming it really was useable on
a 16bit system ...)


> 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
> >> http://www.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html
> >> 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).

yes, iam fine with the macros


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090115/671d0b76/attachment.pgp>



More information about the ffmpeg-devel mailing list