Frage

Are comments in a c source file removed by the compiler (for example visual c++ and GCC)?

/* ... */

// ...
War es hilfreich?

Lösung

The compiler uses different steps to translate the sourcecode to machine readable code.

The first step, the lexical analysis phase translates the characters to tokens. A token can be an identifier, a literal value, a reserved word, or an operator.

Comments and whitespace are mostly ignored during this phase. They are only used to separate different tokens.

In the next steps, there is no concept for a comment or a whitespace, so yes, they are removed while compiling.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top