CKTIS / C
comments and documentation — concept C23
C supports block comments `/* ... */` and line comments `// ...`; comments disappear during an early translation phase, and block comments cannot nest. Documentation should record contracts and reasons for constraints rather than repeat obvious code.
Version: C23
Syntax
comments and documentationC supports block comments /* ... */ and line comments // ...; comments disappear during an early translation phase, and block comments cannot nest. Documentation should record contracts and reasons for constraints rather than repeat obvious code.
In practice, a function comment should state pointer ownership, size units, result meaning, and failure conditions. A short comment inside an algorithm is useful when it explains a non-obvious invariant or why operations must occur in that order.
A /* sequence inside a block comment does not open another level, so the first */ ends the whole comment and can expose accidental code. A macro cannot reliably “comment out” arbitrary text; use controlled #if 0 for disabled code and remember that the text must still be valid preprocessing input.
Examples
#include <stdio.h>
int main(void) {
/* A block comment cannot be nested. */
int value = 6; // The line comment ends at the newline.
printf("%d\n", value + 1);
return 0;
}
Result
7
C supports block comments `/* ... */` and line comments `// ...`; comments disappear during an early translation phase, and block comments cannot nest. Documentation should record contracts and reasons for constraints rather than repeat obvious code.