Gamestudio Links
Zorro Links
Newest Posts
Max Number of Strategies in /Strategy folder
by Martin_HH. 06/17/26 07:16
Z9 getting Error 058
by jcl. 06/16/26 09:51
How to select between IB accounts by script?
by AndrewAMD. 06/13/26 15:44
Zorro tutorial ideas?
by AndrewAMD. 06/13/26 15:01
Zorro 3.01 recoded MMI function issue
by 11honza11. 06/13/26 11:40
Stooq now requires an API key
by AndrewAMD. 06/11/26 17:55
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 3,614 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Student_64151, Koti, curry, DeepxKalsi, Samed
19219 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
overloaded functions and pointer-conversion query #338926
08/22/10 19:34
08/22/10 19:34
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Hi all.

Question 1> I believe the lite-c does some form of auto-object-to-pointer
conversion when dealing with NON-overloaded functions.
ie. func(my.x); --> void func(VECTOR* pos) conversion.
Can someone please explain the 'steps' this conversion follows
in deciding whether to convert, and what to convert to, etc.

Question 2> I believe this auto-conversion DOESNT apply when dealing with OVERLOADED functions.
Is it "theoretically" possible for the engine to be upgraded to auto-convert overloaded functions too?
If not, why not?

Thanks guys.





"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: overloaded functions and pointer-conversion query [Re: EvilSOB] #338930
08/22/10 19:52
08/22/10 19:52
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline
Serious User
pegamode  Offline
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
As far as I know auto-conversion should apply also with overloaded functions, but there was a long time bug using strings in overloaded functions, but it was fixed in 7.83.2:

Quote:
Overloaded functions weren't found by the compiler when the function prototype expected a STRING* argument, but was called with a char* or char[] constant (all A7 versions; fixed in 7.83.6). Workaround: Define the overloaded prototype with a char* parameter.


Re: overloaded functions and pointer-conversion query [Re: pegamode] #338932
08/22/10 20:06
08/22/10 20:06
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Originally Posted By: from the 7.86 manual
When calling overloaded functions, make sure that argument types exactly match one of the defined functions. The automatic type conversion and pointer detection of the lite-C compiler does not happen here. That means you must really use the C++ & operator for pointers.


And for me it is mostly the VECTOR* that give me problems. There are so many ways to call it...

example: this code works fine...
Code:
void funcA(VECTOR* pos)
{   ...   }

void funcB(VECTOR* pos, int height)
{   ...   }

action play()
{
   funcA(my.x);
   funcB(my.x, 1);
}


But this will fail on compile
Code:
void func(VECTOR* pos)
{   ...   }
void func(VECTOR* pos, int height)
{   ...   }


action play()
{
   func(my.x);
   func(my.x, 1);
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: overloaded functions and pointer-conversion query [Re: EvilSOB] #338933
08/22/10 20:13
08/22/10 20:13
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Try using ((VECTOR*)(&(my.x))) wink

Re: overloaded functions and pointer-conversion query [Re: Lukas] #338935
08/22/10 20:21
08/22/10 20:21
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Yeah Lukas, that will "work"...
But with UN-overloaded it works fine without re-casting.

Thats what Im asking about, the AUTO conversions...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: overloaded functions and pointer-conversion query [Re: EvilSOB] #340633
09/06/10 09:18
09/06/10 09:18
Joined: Jul 2000
Posts: 28,108
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,108
Frankfurt
Overloaded functions don't use automatic var->pointer conversion. Otherwise there would be too many special cases to consider. So when using overloaded functions, make sure that you pass a pointer when one is excepted. The type of the pointer is normally converted, though.

Re: overloaded functions and pointer-conversion query [Re: jcl] #340642
09/06/10 10:02
09/06/10 10:02
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
OK, thanks. I suspected as much.

So overloaded functions cant do what I wnt in "this" instance.

Thanks anyway...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

Moderated by  old_bill, 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