standard for documenting conditional preprocessor directives?

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

 



  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 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?

rday

-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================
-
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