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
0 registered members (), 16,302 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
events in structs #354677
01/20/11 22:19
01/20/11 22:19
Joined: Apr 2009
Posts: 138
Germany
T
Toryno Offline OP
Member
Toryno  Offline OP
Member
T

Joined: Apr 2009
Posts: 138
Germany
Hi, is there any possibility to make struct including one or more events which can be used later by other functions? I tried with the following code and some similar code but this all didn't work.

Code:
void evt () {
	storage = 1;
}

typedef struct {
	var storage;
	EVENT evt;
	
} test_struct;


function main() {
	test_struct bla;
	bla.evt;
	printf("%f", bla.storage);
}



Last edited by Toryno; 01/21/11 04:44.

Thanks for reading, thinking, answering wink
Re: events in structs [Re: Toryno] #354701
01/21/11 07:32
01/21/11 07:32
Joined: Jan 2011
Posts: 120
United States
Logan Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
What sort of way is this code failing? I think the idea is getting confused because you've included EVENT evt; in the struct, and this is the same name as the void above... but by doing this, you haven't actually created any relationship between those two things, you've simply defined a function evt() which happens to have the same name as an element in test_struct. Better to define a function pointer within the struct, then explicitly set it TO evt(), then try to call it.

Code:
typedef struct {
...
void* event;
} test_struct;

...
// then later on, inside a function somewhere
test_struct bla;
bla.event = evt;
bla.event(); // this calls evt()




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