Question

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

/* ... */

// ...
Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top