Gamestudio Links
Zorro Links
Newest Posts
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
Zorro version 3.0 prerelease!
by TipmyPip. 02/24/26 17:09
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
4 registered members (Martin_HH, TipmyPip, AndrewAMD, Grant), 5,825 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Lite-C behaviour differs from C/C++ #265172
05/10/09 21:47
05/10/09 21:47
Joined: Sep 2003
Posts: 9,859
F
FBL Offline OP
Senior Expert
FBL  Offline OP
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Let's say we have following line:

Code:
if (psTemp == NULL || 
(psTemp != NULL && psTemp->vStackable == 0)
)


I'd expect that if ps Temp is equal to NULL, the statement is true and everything is fine.

Lite-C however even processes the second condition even if the first one is already true. This results in a crash message in case psTemp is NULL, as it doesn't have a vStackable property then.

So this has to be worked around in Lite-C

Code:
	if (psTemp != NULL)
	{
		if (psTemp->vStackable == 0)
		{
			vNew = 1;
		}
	}
	else
	{
		vNew = 1;
	}
	
	if (vNew != 0) 


This is pretty annoying. Can this behaviour be changed in the future?

Re: Lite-C behaviour differs from C/C++ [Re: FBL] #265199
05/11/09 06:10
05/11/09 06:10
Joined: Jul 2000
Posts: 28,075
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,075
Frankfurt
You're right. I'll document this first, and will change it in the future.

Re: Lite-C behaviour differs from C/C++ [Re: jcl] #265202
05/11/09 06:58
05/11/09 06:58
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline
Serious User
pegamode  Offline
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
That's good news that it will be changed in future.

I wanted to post this behaviour for some weeks, but always forgot it to do.

Re: Lite-C behaviour differs from C/C++ [Re: pegamode] #265203
05/11/09 07:15
05/11/09 07:15
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
JCL : Do you THINK, at this early stage, that your fix will also rectify a minor, related lite-c issue I have as well?
Code:
if((ent!=NULL)&&(ent.alpha>=10))  beep();    //crashes if ent is null
//my workaround
if(ent!=NULL)  if(ent.alpha>=10)  beep();    //works fine (no beep) if ent is null
If it doesnt fix it, its not worth worrying about, I'd would just like to know...



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Lite-C behaviour differs from C/C++ [Re: EvilSOB] #265205
05/11/09 07:57
05/11/09 07:57
Joined: Jul 2000
Posts: 28,075
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,075
Frankfurt
This is the same. Lite-C evaluates all terms in an expression for getting the result. This is different to C where the terms are evaluated from left to right, and skipped when they don't affect the result.

Re: Lite-C behaviour differs from C/C++ [Re: jcl] #265211
05/11/09 08:15
05/11/09 08:15
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Kewl, thanks


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Lite-C behaviour differs from C/C++ [Re: EvilSOB] #265218
05/11/09 08:23
05/11/09 08:23
Joined: Sep 2003
Posts: 9,859
F
FBL Offline OP
Senior Expert
FBL  Offline OP
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
That's good news, thanks.


Moderated by  jcl, Nems, Spirit, Tobias 

Gamestudio download | 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