Now, we all know that // makes a comment. But I have a question about the compiling of the program? Say you were to make a comment with a whole bunch of underscores to signify a different section of code. Does the amount of comments written in the source code increase the size of the final executed file or make the program any slower, even by a microsecond? Or does C++ just skip right over the comments or automatically delete them while compiling? Thanks in advance =)

Recommended Answers

All 5 Replies

As far as I know, the compiler should just ignore the comments while parsing your code. So it should not have any effect on executable size or speed.

stilllearning is correct. The compiler is only interested in the statements that do something so comments are not part of the compiled program.

I see. Thank you very much =)

>Does the amount of comments written in the source code increase the size of the
>final executed file or make the program any slower, even by a microsecond?
No, comments are stripped from the source during compilation.

Comments are ignored during the parsing stage. It has totally no effect on the final executable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.