[FFmpeg-devel] [PATCH] libavformat: Add H264 API test

Michael Niedermayer michaelni at gmx.at
Mon Jun 22 13:52:17 CEST 2015


On Mon, Jun 22, 2015 at 12:50:21PM +0300, Ludmila Glinskih wrote:
> I really don't know how to avoid warnings in printf.

in:
libavformat/api-h264-test.c: In function ‘video_decode_example’:
libavformat/api-h264-test.c:113:25: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘int64_t’ [-Wformat]
libavformat/api-h264-test.c:113:25: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 7 has type ‘long unsigned int’ [-Wformat]

gcc counts the number of arguments to the function not just the
printed arguments so in
printf("%d, %10"PRId64", %10"PRId64", %8d, %8d, 0x%08"PRIx32"\n",
         ^
         is the 2nd
              ^
              is the 3rd

its not exactly logic but thats how gcc counts, this can easily confuse
one
so the 5th is the first "%8d" which needs to be a PRId64 or similar
the 7th is the '0x%08"PRIx32"' which needs to be type matching
long unsigned int which is "0x%08lx"
i wonder if theres a complete and clean list somewhere for all the
printf() strings for all types, They are in principle written in the
C specification but its not exactly the best text to quickly find one
for a given type.
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf

Thanks

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150622/b252c33f/attachment.asc>


More information about the ffmpeg-devel mailing list