gperf -- #define for if (0) ; else for

Benjamin Kaduk kaduk at MIT.EDU
Mon Oct 21 04:18:29 UTC 2013


On Sun, 20 Oct 2013, Sean Bruno wrote:

> I don't even know why this is a thing in our code base.  Its generating
> a lot of clang noise due to -Wdangling-else
>
> /usr/src/gnu/usr.bin/gperf/../../../contrib/gperf/src/search.cc:417:15:
> warning: add explicit braces to avoid dangling else [-Wdangling-else]
>              for (int i3 = imax; i3 >= 0; i3--)
>              ^
> /usr/src/gnu/usr.bin/gperf/../../../contrib/gperf/src/search.cc:39:22:
> note: expanded from macro 'for'
> #define for if (0) ; else for
>                     ^
>
> I see no reason to continue this and propose the removal of the line in
> contrib/gperf/src/search.cc
>
>     37
>     38 /* Assume ISO C++ 'for' scoping rule.  */
>     39 #define for if (0) ; else for

StackOverflow (!) [1] suggests that they're a workaround for a bug in old 
versions of Visual Studio.

Someone hand Sean the danish axe, please.

-Ben

[1]
  http://stackoverflow.com/questions/984878/what-is-the-possible-use-for-define-for-if-false-else-for


More information about the freebsd-hackers mailing list