10/4 Which of the following #endif comment in C is better?
(a) #ifdef FOO
... foo code ...
#else
.... non-foo code ...
#endif /* FOO */
(b) #ifdef FOO
... foo code ...
#else
... non-foo code ...
#endif /* !FOO */
Thanks.
\_ a actually makes sense.
\_ to normal people, but I'm sure that some 1337 l1nux d00d5 will
like (b) better. (Trust me, I've seen stranger)
\_ Ah, the GNU way.
\_ please learn to spell, its GN00 not GNU.
- 1337_5P34Kd
\_ The first one is better, since !FOO is usually used to match
a ifndef FOO.
\_ I don't get the joke.....
\_ Me either. Some sort of ultra nerd thing I guess.
\_ It's not a joke. I'm trying to figure out how to write my
code. Thanks for the responses so far.
\_ Uhm... ok. You realise its the same code and only the
final comment is different by a single character? Neither
way is "better". Comments are there to make sense of your
code for others. I don't think you need that comment at
all unless you work with monkeys in which case it won't
matter anyway. Good luck!
\_ Yes, only the final comment differs by a single
character. I should've mentioned that the code between
the #if and #else and between the #else and #endif is
usually pretty long, about 100 lines or so. So I want
to see which comment makes the code more clear to
others.
\_ Oh. In that case I'd use the first one.
\_ Okay. Thanks.
\_ A. the #endif goes with the #if, not with the #else. Otherwise,
it'd be #endelse. |