Skip to main content
gamedev.net
🔒 Locked

// vs. /**/

Started by antareus 8 replies 750+ views
Original Post
antareus
antareus
I saw someone on a forum once say that // comments are faster than /**/ comments. But I don''t think they did. So I made a little test program and looked at the assembly output. They produced the EXACT SAME THING! So I think he was wrong. What do you think?
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
billybob
billybob
bad joke.

in any case, i prefer // so i can comment off large chunks of things without the stupid */ ending the comment before i want.
antareus
antareus
Yeah I know, I just wondered how other vs. posts could make it to two pages.

Not being able to nest the /* comments is the most annoying thing ever too.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Nervo
Nervo
When you make a binary exe the compiler removes all comments anyhow. It has no effect in that scenario.
Well, R2D22U2..
Xgkkp
Xgkkp
*xgkkp blinks*
Sneftel
Sneftel

// comment


/* Comment that is very long. So long, in fact, that in order
to present it correctly, it''s necessary to use several lines.
*/


#if 0
commented.out(code);
#if 0
which.can = be.nested; /* including comments */
#endif
but = must ? be : syntactically - correct;
#endif



How appropriate. You fight like a cow.
daerid
daerid
actually, I don''t think that it must be syntactically correct. Anything between an #if/endif preprocessor block that evaluates to false/0 doesn''t get included in the compilation proccess at all.
daerid@gmail.com
Way Walker
Way Walker
quote:
Original post by daerid
actually, I don''t think that it must be syntactically correct. Anything between an #if/endif preprocessor block that evaluates to false/0 doesn''t get included in the compilation proccess at all.


It has to fit the syntax of the preprocessor because the preprocessor still has to evaluate it. Granted, the preprocessor doesn''t understand all of C''s syntax, but a notable exception would be that it understands string literals. (#define''s don''t affect the content of a string literal) So, for instance, you have to at least make sure you properly nest your quote marks. Also think a backslash at the end of a line might cause problems, depending on the context.
JohnBolton
JohnBolton
As an alternative to trying to figure out if "/**/" or "//" is faster, consider optimizing away the entire comment.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.