This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Coding convention: use of `!x' vs. `! x'
- To: gcc at gcc dot gnu dot org
- Subject: Re: Coding convention: use of `!x' vs. `! x'
- From: Jamie Lokier <egcs at tantalophile dot demon dot co dot uk>
- Date: Tue, 26 Sep 2000 13:36:45 +0200
On the subject of `!x' vs. `! x', I'd like to point out that different
operators have always been treated differently.
Does anyone write `a -> b' or `a . b'? I didn't think so.
Does anyone write `a = * b;'? Sometimes, but not all that often.
Casts. Most of GCC and indeed GNU code generally includes a space
between the cast and the value: `(unsigned int) x'.
Unary operators that aren't casts: `++x', `x++', `*x', `!x' etc. seem to
be the norm. However, `* x' and `- x' do appear from time to time.
Function calls include space between the function name and arguments,
including when the function is a pointer expression like `a->b (args)'.
When the function name is surrounded by parantheses, a space is still
included just as with cases: `(*fn) (args)'.
Binary expression operators are generally surrounded by whitespace.
However, `a->b', `a.b' and for C++, `a::b' seem to be the norm for
syntactic operators.
Occasionally in non-GCC code I see space used to indicate grouping:
`a + 2*b' for example. I think it looks equally clear with or without
the spaces there, and for consistency I tend to write `a + 2 * b'.
enjoy,
-- Jamie