[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: removing unnecessary parentheses in #if defined (FOO)
From: |
Jim Meyering |
Subject: |
Re: removing unnecessary parentheses in #if defined (FOO) |
Date: |
Wed, 25 Jan 2006 09:03:15 +0100 |
Bruno Haible <address@hidden> wrote:
...
> I agree with this. If this were the only piece of C code that exists,
> then of course its readability would behave as you say.
>
> The other point is that readability depends on what the reader is used to,
> or is familiar with.
>
> you what than way opposite the in written is that sentence a Reading
> its do cannot brain reader's the because Simply .hard is to used are
> .way usual the matching pattern
Of course, if removing these parentheses made the code as unreadable
as right-to-left English, we wouldn't be discussing it.
> This is also the reason for the existence of the GNU coding style: code
> is easier to read if it follows the usual visual and semantic patterns.
FWIW, the GNU coding standards does not address this issue,
other than by an anachronistic example:
#if defined (__STDC__) || defined (WINDOWSNT)
People using gnulib should be more accustomed to the paren-free style,
since, at least in gnulib/lib/*.[ch], files with the paren-free variant
outnumber the other by 5:1
$ grep -lE '^#.*defined [^ (]' *.[ch]|wc -l
102
$ grep -lE '^#.*defined ?\(' *.[ch]|wc -l
20
If you count lines, it's skewed to 3:1 by getloadavg.c's 46(!)
offending lines.
BTW, I noticed a few of the gnulib ones that I'd made exceptions
for in coreutils, so have just `fixed' two of them:
* fileblocks.c: Remove useless parentheses in cpp directive.
* readutmp.h: Likewise.
Re: socket.h, Simon Josefsson, 2006/01/24