Topic: comment after #if/#endif ???
Author: juliano@cs.unc.edu (Jeffrey Juliano)
Date: 1999/08/29 Raw View
Is this allowed under the standard?
Is it required to compile?
Does it have the semantics I would expect?
#if 0 // was ...
// old code
#else // changing to ...
// new code
#endif // ... end change
thanks,
-jeff
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Jeff Rife <jrife-news@nabs.net>
Date: 1999/08/30 Raw View
Jeffrey Juliano (juliano@cs.unc.edu) wrote:
> #if 0 // was ...
> // old code
> #else // changing to ...
> // new code
> #endif // ... end change
> Is this allowed under the standard?
Yes.
> Is it required to compile?
Yes.
> Does it have the semantics I would expect?
If you expect that the comments after your #if/#else/#endif are ignored,
then yes.
The standard says that legal comments are replaced by a non-newline
whitespace, and end of line comments are legal at the end of *any* line.
As long as you don't do line continuation with a backslash, like:
#if 0 // was ... \
func();
you are OK. The line continuation above results in the function call
becoming part of the #if 0, and thus, part of the *comment* after the
#if 0, which would probably not be what you intended.
--
Jeff Rife | "I'm reading a great John Grisham novel...it's
19445 Saint Johnsbury Lane | about a young Southern lawyer who fights an
Germantown, MD 20876-1610 | evil corporate giant."
Home: 301-916-8131 | -- Dick Solomon, "3rd Rock from the Sun"
Work: 301-770-5800 Ext 5335 |
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]