[FFmpeg-devel] [PATCH 1/4] tableprint: Fix use of a size_t print with MSVC

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Jan 15 22:31:17 CET 2013


On Tue, Jan 15, 2013 at 04:28:02PM -0500, Derek Buitenhuis wrote:
> %zu was introduced in C99, so MSVC has its own way to handle it,
> namely %Iu.
> 
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
> ---
>  libavcodec/tableprint.h |   14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h
> index 1b39dc6..26d063e 100644
> --- a/libavcodec/tableprint.h
> +++ b/libavcodec/tableprint.h
> @@ -71,10 +71,20 @@ void write_uint32_t_2d_array(const void *, int, int);
>  void write_float_2d_array   (const void *, int, int);
>  /** @} */ // end of printfuncs group
>  
> +/*
> + * MSVC doesn't have %zu, since it was introduced in C99,
> + * but has its own %Iu for printing size_t values.
> + */
> +#if defined(_MSC_VER)
> +#define FMT "Iu"
> +#else
> +#define FMT "zu"
> +#endif

I don't mind, but personally I think the size_t type is just a bad idea.
Using e.g. int and ordinary %d seems preferable to me.
It's not like we'll ever have a table with more than 2 billion entries
(looking forward to a 4 GB ffmpeg binary...).


More information about the ffmpeg-devel mailing list