Single line comments in Ansi
I'm used to //
to mark a single line comment from Java and Visual Studio and was surprised that this does not exist for Ansi-C. Using /* my comment */
is quite annoying. Is there any other way to mark a single line comment when using Ansi-C?
ANSI-C,不,但目前的C99标准允许它们。
You could also write a macro:
#define COMMENT(x)
int main() {
COMMENT(Hi there)
return 0;
}
Other than that nothing obvious in ANSI C - you're correct in noting that /* */
style is not valid in ANSI C 89
Well ...
ANSI C is C99; and it allows comments starting with //
extending to the end of the line.
In the previously published standard (C89/C90) the //
comments weren't described (but many compilers accepted them as an extra anyway).
You have yet another option for commenting: the #if 0
/ #endif
construction (usually used for commenting out "inactive" code)
/* ... */ #if 0 This is a comment #endif /* ... */链接地址: http://www.djcxy.com/p/20568.html
上一篇: Java中的unicode换行符(\ u000d)
下一篇: Ansi中的单行注释