Liste des Groupes | Revenir à cl c |
On 21/03/2024 15:20, David Brown wrote:"#if 0", presumably.On 21/03/2024 07:19, Lawrence D'Oliveiro wrote:And sometimes, when it's not a really a comment, but rather a block of code I don't want right now:The original comment delimiters in C were copied from PL/I: everything>
between “/*” and “*/” is a comment, even extending across multiple lines.
Pascal had something similar, only the delimiters were “{” and “}”, or
“(*” and “*)” for compatibility with machines with restricted character
sets.
>
For some reason, the Ada folks decided block comments were not a good
idea, and so their rule was that anything after “--” up to the end of the
line was a comment. And C++ adopted a similar rule, using “//” as their
to-end-of-line comment marker, though of course they also kept C-style
block comments. Java also keeps both these styles.
>
Since then, I’ve seen newer programmers gravitate towards the rest-of-line
form in preference to the block form, and I’m not sure why. I’m fond of
writing things like
>
/*
A very simple HTML/XML entity-escape function--why isn’t this
part of the standard Java API?
*/
>
which involve less typing than
>
//
// A very simple HTML/XML entity-escape function--why isn’t this
// part of the standard Java API?
//
>
I use both - block comments when making a comment block, and line comments when adding comments to the end of a line. That seems pretty obvious to me.
#ifdef 0
...Yes, I do that too. But if it is more than just a fairly trivial amount of code, and not just for quite tests during development, then I hugely prefer to give the block a name:
#endif
Les messages affichés proviennent d'usenet.