[FFmpeg-devel] [PATCH] Replace all %t print prefixes with macros

jamal jamrial at gmail.com
Sun Aug 26 06:47:25 CEST 2012


On 21/08/12 7:33 PM, jamal wrote:
> On 21/08/12 4:31 AM, Nicolas George wrote:
>> Le quintidi 5 fructidor, an CCXX, jamal a écrit :
>>> Some C libraries don't support the %t lenght specifier, resulting in print functions
>>> outputting said string literally and ignoring the argument
>>
>> Can you be a little bit more specific in placing the blame?
> The one i know about is Windows (msvcrt.dll). No idea if there are others.
>>
>>> -    av_log(NULL, AV_LOG_DEBUG, "subtitle_packet size=%td\n", q - outbuf);
>>> +    av_log(NULL, AV_LOG_DEBUG, "subtitle_packet size=%" PRIdPTR "\n", q - outbuf);
>>
>> Note that %td is for ptrdiff_t while PRIdPTR is for intptr_t; there is no
>> guarantee that they are the same type. In segmented architectures, I guess
>> ptrdiff_t would be the size of a near pointer while intptr_t would be the
>> size of a far pointer.
>>
>> It probably does not change anything on supported architectures, though, but
>> I am not completely sure about that.
>>
>> Regards,
> At least on Windows and Linux (x86 and x86_64) PRIdPTR seems to work. But if it really is not an option, maybe use some custom macros? Defined in a new header like libavutil/inttypes.h which would include the system inttypes.h, and which could for example be included wherever is needed in place of the later.
> As things are now, at least on Windows builds quite a few log messages are outputting %td, %ti, and %zu instead of a numeric value, so we should find a way to solve this.
> 
> On Windows, %I replaces both %t and %z, so maybe something like:
> 
> #ifdef _WIN32
> #define AV_PRIdT "Id"
> #define AV_PRIiT "Ii"
> #define AV_PRIuZ "Iu"
> #else
> #define AV_PRIdT "td"
> #define AV_PRIiT "ti"
> #define AV_PRIuZ "zu"
> #endif
> 
> Then replacing each %t and %z with these macros.
> What do you think?
> 
> Regards.
> 
Opinions? What do you think is the best way to deal with this?
Keeping George's comments in mind, i think that using custom macros like the example above is the best idea.


More information about the ffmpeg-devel mailing list