[Ffmpeg-devel] [PATCH] move utf8 writing to libavutil
Måns Rullgård
mru
Sat Jul 8 23:04:06 CEST 2006
Michael Niedermayer <michaelni at gmx.at> writes:
> Hi
>
> On Sat, Jul 08, 2006 at 08:56:18PM +0100, M?ns Rullg?rd wrote:
>> Justin Ruggles <jruggle at earthlink.net> writes:
>>
>> > Please explain the benefit of the do/while. What does it protect against?
>>
>> Without it,
>>
>> if(whatever)
>> PUT_UTF8(...);
>>
>> will have some quite unintended results without so much as a warning.
>>
>> The idea with a do { } while(0) construct is to turn the entire macro
>> body into a single statement while still keeping the semicolon
>> (usually) placed after the macro invocation part of this same
>> statement. Simply enclosing the body in braces will make the final
>> semicolon form a new, empty statement, which will break things like
>>
>> if(foo)
>> PUT_UTF8(...);
>> else
>> PUT_UTF8(...);
>
> the intended use of thet GET/PUT_UTF8 macros was so that each application
> could easily build their own utf8 reading and writing functions with their
> own get_bits / put_bits system
That may well be, but I still think multi-statement macros should have
a do { } while(0) just in case. It can avoid some nasty and hard to
find errors, and it has no negative effects.
--
M?ns Rullg?rd
mru at inprovide.com
More information about the ffmpeg-devel
mailing list