Gamestudio Links
Zorro Links
Newest Posts
zorro license, IB connection
by miwok. 12/06/23 16:32
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (miwok, AndrewAMD, TipmyPip, 3run, Quad, 1 invisible), 645 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Previous variable value into another variable? [Re: 3dgs_snake] #347073
11/12/10 09:43
11/12/10 09:43
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Woah, 3dgs_snake, what you are doing looks pretty risky.
The compiler will cast your var to an var* when you call the function like you are doing, and that will likely result in a segfault. You may want to use the & operator for this wink


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Previous variable value into another variable? [Re: WretchedSid] #347077
11/12/10 10:25
11/12/10 10:25
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
blush Yes, It was an error when I did it in the first time, but I tested and it seems to run fine, so I didn't change. Also in the the documentation it is said that
Quote:

Lite-C automatically detects if a function expects a variable or a pointer to a variable, so you can usually omit the '&' and just write:
change_variable_p(x); // now x is 11

grin But I totally agree that it is a best practice to use the '&', and it is more clean.

Thanks.

Re: Previous variable value into another variable? [Re: 3dgs_snake] #347079
11/12/10 10:59
11/12/10 10:59
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Okay, didn't knew that, thats horrible shocked


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Previous variable value into another variable? [Re: WretchedSid] #347083
11/12/10 11:40
11/12/10 11:40
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
I think they did that to make Lite-C more easy to learn for people who don't have strong C/C++ knowledge. I think it is a good thing grin

Re: Previous variable value into another variable? [Re: 3dgs_snake] #347105
11/12/10 16:24
11/12/10 16:24
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
I rather think they did that to make converting code from C-Script to Lite-C easier. E.g. vec_set(my.x,you.x); would normally have to be vec_set(&(my->x),&(you->x)); and so on.

For learning I even think it's a bad thing because it will be harder for people to learn "real" C/C++ after they learned Lite-C.

Re: Previous variable value into another variable? [Re: Lukas] #347132
11/12/10 18:34
11/12/10 18:34
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
This can be switched off via PRAGMA_POINTER, though. AFAIR the automatic pointer detection doesn't work in all situations anyway.

Re: Previous variable value into another variable? [Re: Saturnus] #347133
11/12/10 18:38
11/12/10 18:38
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
I know, but I don't want to to this either, because I do NOT want to have to write vec_set(&(my->x),&(you->x));
I'd prefer to have an API that doesn't require such simplification, like:
my->setPos(you->GetPos());

But Lite-C isn't even object-orientated and completely changing the API would mean dropping backwards-compatibility.

Page 2 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