Steven Woody said:
>
> Richard Heathfield wrote:
>> Steven Woody said:
>>
>> > thanks for all your advices. commenting out all headers
>>
>> Please, please, please don't do this. If you want to rip them out
>> temporarily, do it like so:
>>
>> #if 0
>> #include "foo.h"
>> #include "bar.h"
>> #include "baz.h"
>> #include "quux.h"
>> #endif
>
> i've not seen big difference between this method and that of commting.
The obvious difference is that "commenting out" code is an abuse of the
syntax. But perhaps you're not so interested in clarity, and want a more
practical motivation. Okay, here it is:
foo(); /* do the foo thing */
if(condition) /* we only want to bar if there's an 'r' in the month */
{
bar(); /* this will use the default directory, C:\bar\ */
baz(); /* don't forget to baz everything back to normal */
}
Observe the problem with "commenting out" this code:
/*
foo(); /* do the foo thing */
if(condition) /* we only want to bar if there's an 'r' in the month */
{
bar(); /* this will use the default directory, C:\bar\ */
baz(); /* don't forget to baz everything back to normal */
}
*/
See the difficulty? Only the foo() call has been "commented out". And now
you have a syntax error on the last line - "unmatched closing comment" or
similar.
Now let's do it properly:
#if 0
foo(); /* do the foo thing */
if(condition) /* we only want to bar if there's an 'r' in the month */
{
bar(); /* this will use the default directory, C:\bar\ */
baz(); /* don't forget to baz everything back to normal */
}
#endif
No syntax error. No problem with existing comments. And to undo it, you need
only change a single character (change 0 to 1) - and of course it's just as
easy to re-do it.
>> Then, as you discover you need them, fish them out of the #if and into
>> the code proper.
>>
>> Comment syntax is for adding something extra to the code, not for taking
>> something away.
>
> how to understand this ? i am so interesting
Unmatched closing comment.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)