emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [C source] Inconsistent comments on preprocessor conditionals


From: Sergey Organov
Subject: Re: [C source] Inconsistent comments on preprocessor conditionals
Date: Fri, 08 Jul 2022 19:28:44 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Akib Azmain Turja <akib@disroot.org> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> Date: Sat, 09 Jul 2022 01:33:26 +1200
>>> From: Phil Sainty <psainty@orcon.net.nz>
>>> Cc: Akib Azmain Turja <akib@disroot.org>, emacs-devel@gnu.org
>>> 
>>> On 2022-07-09 00:55, Eli Zaretskii wrote:
>>> > You mean, the comment for the #endif line?  It doesn't really matter
>>> > how you comment that, because both comments tell the same: the
>>> > #ifdef'ed conditional block ends here.  The differences in this case
>>> > are purely stylistic.
>>> 
>>> The "#endif /* not FOO */" version provides the extra information that
>>> there *is* an "#else" clause
>>
>> No, it doesn't, because the conditional could start with #ifndef
>> instead.
>
> Then we can do like the following:
>
> #ifndef FOO
> ...
> #else /* not !FOO */
> ...
> #endif /* not !FOO */

It should then rather be something like:

#ifndef FOO
#else  /* not ndef FOO */
#endif /* not ndef FOO */

as there also could be:

#if !FOO
#else  /* not !FOO */
#endif /* not !FOO */

>From that POV, the original should better be:

#ifdef FOO
#else  /* not def FOO */
#endif /* not def FOO */

to tell it from:

#if FOO
#else  /* not FOO */
#endif /* not FOO */

Just for mentioning, for myself I've adopted shorter style:

#ifdef FOO
#else  /*! def FOO */
#endif /*! def FOO */

where "/*!" reads like a specific single token clearly separate from the
#if condition, thus avoiding confusion.

-- 
Sergey Organov



reply via email to

[Prev in Thread] Current Thread [Next in Thread]