tags:

views:

170

answers:

0

Possible Duplicate:
Why are there sometimes meaningless do/while and if/else statements in C/C++ macros?

In the source code of OpenJDK I found this macro:

#define PUTPROP(props, key, val) \
    if (1) { \
    // some code
    } else ((void) 0)

It is used as one would expect, e.g.:

PUTPROP(props, "os.arch", sprops->os_arch);

(If you are interested, it is in the file jdk/src/share/native/java/lang/System.c)

I suppose this is some kind of optimization thing. Can somebody explain or provide a link? This is hard to google.

And before someone asks: Yes, I'm just curious.