Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (NewbieZorro, Grant, TipmyPip, AndrewAMD), 13,346 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Function returning a short #134712
06/08/07 10:18
06/08/07 10:18
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline OP
Expert
Excessus  Offline OP
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
I'm trying to create a function that should return a short. Here is my test code:

Code:

short testfunc()
{
return 100;
}
int main()
{
testfunc();
}



This results in an error:
Quote:

Error in 'MAIN' line 55: machine code generator: cannot translate SETRETV:::SHORT
< return 100; >





Am I doing something very stupid?

The manual says this:
Quote:

While C-Script can only return a var, lite-C, C, or C++ can return any variable or pointer type. Instead of "function", the function is then defined with the returned type, like float, ENTITY*, or whatever.




Re: Function returning a short [Re: Excessus] #134713
06/08/07 11:01
06/08/07 11:01
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt

Re: Function returning a short [Re: jcl] #134714
06/08/07 14:18
06/08/07 14:18
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline OP
Expert
Excessus  Offline OP
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Thank you, I'll use an int for now.

I noticed another quirk, although it might also have been reported before (couldn't find anything though):
Code:

// Works:
char chr = 5;
short shrt = chr;

// Fails:
char chr = 5;
short shrt = (short)chr;



The second piece of code gives me a "Cannot translate CONV:CHAR::SHORT" error. Kinda strange since implicit casting (without "(short)") seems to work fine.


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

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