On Mon, 27 Aug 2007 09:47:09 -0400 (EDT) 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 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? Your example almost matches my preference/style, but there is no Linux kernel "standard" for this AFAIK. I would probably use /* SNAFU */ on the #endif line, so that it's consistent with the case of no #else block, but I see the case for using !SNAFU as well. --- ~Randy *** Remember to use Documentation/SubmitChecklist when testing your code *** - 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