Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,119 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
/* comment */ #392074
01/18/12 22:43
01/18/12 22:43
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
I have seen many comments inside .c/.h codes while for search of my unsolved answers, and I have noticed that so fare all use this character // comments// for engine compiler to ignore it.
I understand if your using it for 2-3 lines of comments, but when it come to comments that take 10-15 lines of codes using this // for every line I find it to be a lot of unnecessary work.

So here is a little trick I came across that I'm sure most of you knew about it just in case someone didn't, it might make their explanatory comments(witch I appreciate so much) easier to work with:

use this before the comment /* then close it again before the last comment */. Don't leave any working code in between these characters /* function main()*/ your engine will ignore it.

small example:

Code:
/* start of my comment
next line of my comment
another line of comment
and yet another line of comment
etc ......
*/ end of my comment

function main() // using it for one line of comments



Do make shore to close it after you open it, otherwise it will ignore entire code in your file.

I don't know maybe it looks cool or something just using these characters // for each line of comments. I'm all about simple and fast, I hope this helped someone out.

Last edited by Siwler; 01/18/12 22:59.

Honesty will get you far, were dishonesty will get you only so far in life.

Re: /* comment /* [Re: Siwler] #392075
01/18/12 22:49
01/18/12 22:49
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
You got it wrong, it is supposed to be /* ... */

This is the common C comment, no magic laugh

Re: /* comment /* [Re: PadMalcom] #392076
01/18/12 22:58
01/18/12 22:58
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
yes you are right sorry


Honesty will get you far, were dishonesty will get you only so far in life.

Re: /* comment /* [Re: Siwler] #392078
01/18/12 23:04
01/18/12 23:04
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
The problem is that this type of comment isn't greedy but has lazy behavior, so once you have to comment out such a comment it gets pretty nasty...


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: /* comment /* [Re: WretchedSid] #392087
01/19/12 00:34
01/19/12 00:34
Joined: Oct 2006
Posts: 873
S
Shadow969 Offline
User
Shadow969  Offline
User
S

Joined: Oct 2006
Posts: 873
this way of commenting doesn't support embedding comments into each other, besides most editors allow commenting/uncommenting a block with // instead of manually commenting each line.

Re: /* comment /* [Re: Shadow969] #392104
01/19/12 10:33
01/19/12 10:33
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
I also hate the behavior, that the first */ leaves the "comment space"

This way its hard to quickly comment out a large codeblock when
there are "subcomments" with /* */ in it.

The last */ should determine the end of the commentblock.
But on the other hand this is a reliquia from the 70s,
and cant be changed for compatability reasons.

Re: /* comment /* [Re: Damocles_] #392105
01/19/12 10:43
01/19/12 10:43
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Actually it could be changed as existing code wouldn't break =/
But yeah, /* */ is the old style of commenting (// is C89 or C99?!) and should be used careful.

Oh, and thanks for repeating me guys tongue


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: /* comment /* [Re: WretchedSid] #397434
03/19/12 09:26
03/19/12 09:26
Joined: Apr 2008
Posts: 650
Sajeth Offline
User
Sajeth  Offline
User

Joined: Apr 2008
Posts: 650
When commenting out parts of the code for testing, just do it like this:
Code:
/*
void foobar()
{
dosomething();
dosomethingelse();
}
//*/


When you want to include the code again, you just have to add a / at the beginning. Magic!

For comments, I use the // functions of my editor. I think it feels more distinguishable.

Last edited by Sajeth; 03/19/12 09:29.

Teleschrott-Fan.
Re: /* comment /* [Re: Sajeth] #397443
03/19/12 11:41
03/19/12 11:41
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
use
#ifdef somethingundefined
...
#endif

to comment any comments

Re: /* comment /* [Re: Sajeth] #397596
03/21/12 04:43
03/21/12 04:43
Joined: Jan 2003
Posts: 4,305
Damocles Offline
Expert
Damocles  Offline
Expert

Joined: Jan 2003
Posts: 4,305
Quote:


/*
void foobar()
{
dosomething();
dosomethingelse();
}
//*/



Thats actually a very nifty trick!
Never though about that one, haha.
Speeds up toggeling commenting of blocks quite a bit.

Will use that in Java.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1