All of lore.kernel.org
 help / color / mirror / Atom feed
* standard for documenting conditional preprocessor directives?
@ 2007-08-27 13:47 Robert P. J. Day
  2007-08-27 14:55 ` Robert P. J. Day
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Robert P. J. Day @ 2007-08-27 13:47 UTC (permalink / raw)
  To: kernel-janitors


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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-09-04 18:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-27 13:47 standard for documenting conditional preprocessor directives? Robert P. J. Day
2007-08-27 14:55 ` Robert P. J. Day
2007-08-27 14:57 ` Andre Haupt
2007-08-27 15:15 ` Randy Dunlap
2007-08-27 15:25 ` Andre Haupt
2007-08-27 15:56 ` Robert P. J. Day
2007-09-04 10:13 ` Oleg Verych
2007-09-04 18:19 ` Randy Dunlap
2007-09-04 18:53 ` Oleg Verych

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.