Re: standard for documenting conditional preprocessor directives?

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

 



On Mon, Aug 27, 2007 at 09:47:09AM -0400, Robert P. J. Day wrote:
> 
>   is there an understood standard for documenting conditional
> preprocessor directives so you can more easily follow the logic in
> lengthy code segments?
> 
>   consider:
> 
>     #ifdef SNAFU
>     ... very long blah blah ...
>     #else
>     ... equally long woof woof ...
>     #endif
> 
>   if you're perusing the code, and you hit the "#else" or "#endif",
> it's almost impossible to tell what they correspond to, particularly
> if they're mixed in with even more nested directives.  so what's the
> best way to make this more readable?
> 
>   what about something like?
> 
>     #ifdef SNAFU
>     ...
>     #else /* !SNAFU */
>     ...
>     #endif /* !SNAFU */

I would make that latter
	#endif /* SNAFU */
instead, because the #endif refers to the #ifdef and not to the #else
statement.
> 
>   i contend that both of those new comments have value since, without
> them, you wouldn't know what either the "#else" or "#endif"
> represented.  but i'm willing to be disabused of that notion.
> 
>   thoughts?
> 
sounds reasonable. Some people seem to hate comments in preprocessor directives
though.

regards,

Andre
-
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux