954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C++ Comments

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 =)

DanDaMan
Newbie Poster
13 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

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
Posting Whiz
309 posts since Oct 2007
Reputation Points: 161
Solved Threads: 43
 

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

WaltP
Posting Sage w/ dash of thyme
Moderator
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

I see. Thank you very much =)

DanDaMan
Newbie Poster
13 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

>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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

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

Denniz
Posting Pro in Training
429 posts since Sep 2008
Reputation Points: 118
Solved Threads: 15
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You