It is currently Wed Sep 08, 2010 6:08 am

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Multi Line Comments [AVOID]
PostPosted: Wed Jun 24, 2009 9:53 am 
Joined: Tue Dec 02, 2008 5:59 am
Posts: 82

Well, if you do have multi-line comments you'd get a 'warning' in the compiler log. I just noticed that the program skips code if you put it close to the multi-line comment (Maybe not skip but it fataly ignores something).

ex:
Code:
//---COMMENT---\\
//----------------\\
while(Running)
{
     //Code Here.
}


I tried to "comment apart" sections of my code and that's how I noticed it. I guess it's a "global" issue which most people do know. But for those who doesn't, now you do!


Offline
 Profile  
 Post subject: Re: Multi Line Comments [AVOID]
PostPosted: Wed Jun 24, 2009 10:04 am 
Site Admin
Joined: Tue Oct 28, 2008 9:55 am
Posts: 185
Location: Indiana

The problem is that you are including the \ after the last comment, which is basically saying this line continues down to the next.

It's like saying:

Code:
//----------------\\ while(Running)
     //Code Here.
}


Offline
 Profile  
 Post subject: Re: Multi Line Comments [AVOID]
PostPosted: Wed Jun 24, 2009 7:24 pm 
Joined: Mon Jun 01, 2009 10:25 am
Posts: 50

Tim wrote:
The problem is that you are including the \ after the last comment, which is basically saying this line continues down to the next.

It's like saying:

Code:
//----------------\\ while(Running)
     //Code Here.
}


Wow. Learn something new everyday. I would have thought the correct behaviour is to ignore everything behind //


Offline
 Profile  
 Post subject: Re: Multi Line Comments [AVOID]
PostPosted: Wed Jun 24, 2009 8:29 pm 
Site Admin
Joined: Tue Oct 28, 2008 9:55 am
Posts: 185
Location: Indiana

Not all languages behave this way, but C++ does. I don't think I know of any syntax highlighters that pick up on it either. It's more commonly seen when you are using preprocessor directives or multi-line strings (to make a long string more readable):

Code:
#define SomeThing "I am\
a multi line string"


Code:
#include <stdio.h>

// asd \
asd
int main() {
    printf("I\
like\
to\
code\
weird");

    return 0;
}


In short, I don't recommend using it :P. I only ever use it in JavaScript when I am building a large string for HTML output:

Code:
var Content = "\
<table>\
<tr>\
</tr>\
</table>\
";


Again, languages are different.

Edit:
PHP is one such language that behaves differently (this will produce an error):

Code:
// Some comment \
Rar
echo "Hi";


Offline
 Profile  
 Post subject: Re: Multi Line Comments [AVOID]
PostPosted: Fri Jun 26, 2009 3:09 pm 
Joined: Thu Apr 16, 2009 1:51 pm
Posts: 25

why not just use C-style comment /* */ to do multiple lines comments?

for temporarily unused code #if 0 is better


Offline
 Profile  
 Post subject: Re: Multi Line Comments [AVOID]
PostPosted: Wed Aug 19, 2009 9:50 pm 
Joined: Wed Aug 19, 2009 9:49 pm
Posts: 1

cjp wrote:
why not just use C-style comment /* */ to do multiple lines comments?

for temporarily unused code #if 0 is better


That's what I do. Not sure why OP isn't doing that as well.


Offline
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


 Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: