C multi-line macro: do/while(0) vs scope block [duplicate]

Possible Duplicates:
What’s the use of do while(0) when we define a macro?
Why are there sometimes meaningless do/while and if/else statements in C/C++ macros?
do { … } while (0) what is it good for?

I’ve seen some multi-line C macros that are wrapped inside a do/while(0) loop like:

#define FOO \
  do { \
    do_stuff_here \
    do_more_stuff \
  } while (0)

What are the benefits (if any) of writing the code that way as opposed to using a basic block:

#define FOO \
  { \
    do_stuff_here \
    do_more_stuff \
  }

1 Answer
1

Leave a Comment