For several years I've been use to the single ('//') comment line in C++. I know in C89 this isn't standard, but it is in C99. Is it common to use it anyway? Is it widely portable? Thanks.
For several years I've been use to the single ('//') comment line in C++. I know in C89 this isn't standard, but it is in C99. Is it common to use it anyway? Is it widely portable? Thanks.
No. If you want to be portable, use:
/* single line comment */
Otherwise, you have to hope it's right for your particular compiler, which by definition, means "not portable".
Quzah.
Hope is the first step on the road to disappointment.
Makes sense. I guess it's in the C spirit too
It's true that it's a C99 standard, but by doing it, you basically force everyone to have a C99 compiler in order to compile your program, and at that, you are forcing them to do this just because of how some COMMENTS are written.
I'd say this: if you are already using other language features which require C99 compliance, then feel free to use all of C99 as you wish, including the //-style comments. But don't do it if that's ALL you are using from C99.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
Got it. And nice to meet another Portlander!
/* Put comments in your code like this. */
// Because your code won't always compile if you put comments in like this