سؤال

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

/* ... */

// ...
هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top