[Ffmpeg-devel] [PATCH] move utf8 writing to libavutil

Måns Rullgård mru
Sat Jul 8 21:56:18 CEST 2006

Justin Ruggles <jruggle at earthlink.net> writes:

> Please explain the benefit of the do/while. What does it protect against?

Without it,


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


This one will give a compilation error, but the reason for the error
won't be obvious without knowledge of the macro.  Besides, it's a
perfectly legitimate thing to want to do.

The idea is that something that looks like a single statement where it
is used should indeed behave like a single statement.

M?ns Rullg?rd
mru at inprovide.com

More information about the ffmpeg-devel mailing list