I noticed Visual C++ 2010 (my current environment) and XCode both allow non-standard single-line comments in my C programs. Since these are both my target platforms, I assume it's fine to use it? VC++ 2010 doesn't support C99, so I'm limited to C89, though I know C99 added support.
-
1what do they allow?John Dvorak– John Dvorak2014-01-20 05:51:56 +00:00Commented Jan 20, 2014 at 5:51
-
Microsoft apparently allows non-standard, single-line comments in C89 projects. I feel like a rebel taking advantage of it.Phil– Phil2014-01-20 06:02:23 +00:00Commented Jan 20, 2014 at 6:02
-
1For C99/C++, yes. But no, in that C89 only has multi-line comments. MS adds single-line comments to use in C89 projects, which is.. quite interesting and rebelling.Phil– Phil2014-01-20 06:12:08 +00:00Commented Jan 20, 2014 at 6:12
-
3@Phil, AFAIK C99 had just standardized what was already a common extension at the time.AProgrammer– AProgrammer2014-01-20 08:14:20 +00:00Commented Jan 20, 2014 at 8:14
-
2Given that it would not be that hard to write a tool to convert single line comments into “standard” comments, the risk is low.Ian– Ian2014-01-28 17:31:07 +00:00Commented Jan 28, 2014 at 17:31
|
Show 3 more comments
1 Answer
Anything that works is fine as long as you don't care about the environments where it doesn't work. If you have no ambitions to compile your code in an environment that doesn't support one-line comments (presumably comments that begin with // and continue to the end of the line), then it's fine.