Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 396 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
about struct function pointer #405763
08/07/12 04:46
08/07/12 04:46
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
can lite_c`s struct save function point,any one know know?likes this,how can do this:

Code:
void*_functionPoint(int id,ENTITY* e){
   //...
}
typedef struct{
   int _beep;
   void* functionPoint(int id,ENTITY* e);
};




development 3d game is interesting!
Re: about struct function pointer [Re: frankjiang] #405766
08/07/12 06:34
08/07/12 06:34
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
Code:
typedef struct 
{
    void *fnPtr;
} MYSTRUCT;

void MYSTRUCT_fnPtr(ENTITY* ent);

void assign_func(ENTITY* ent)
{
ent.x = 256;
}

MYSTRUCT str;

[...]

str.fnPtr = assign_func;

[...]
MYSTRUCT_fnPtr = str.fnPtr;
MYSTRUCT_fnPtr(you);




Visit my site: www.masterq32.de
Re: about struct function pointer [Re: MasterQ32] #405776
08/07/12 09:30
08/07/12 09:30
Joined: Sep 2007
Posts: 101
Luxembourg
K
krial057 Offline
Member
krial057  Offline
Member
K

Joined: Sep 2007
Posts: 101
Luxembourg
@MasterQ32
Afaik, this will not work in Lite-c
You have to indicate the parameters in the function declaration inside the struct too.
Further more, when assigning a function pointer, the struct has to be a pointer too:

Php Code:
typedef struct 
{
	void *fnPtr(ENTITY* ent);
} MYSTRUCT;

void assign_func(ENTITY* ent)
{
	printf("test");
}

MYSTRUCT str;

function main()
{
	MYSTRUCT* temp = &str;
	temp->fnPtr = assign_func;
	temp->fnPtr(NULL);
} 




regards Alain

Re: about struct function pointer [Re: krial057] #405778
08/07/12 09:31
08/07/12 09:31
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
it works, because i just store the function pointer and not a prototype
for this i'm taking just some empty prototype and fill it with the correct funciton ptr


Visit my site: www.masterq32.de
Re: about struct function pointer [Re: MasterQ32] #405780
08/07/12 10:14
08/07/12 10:14
Joined: Sep 2007
Posts: 101
Luxembourg
K
krial057 Offline
Member
krial057  Offline
Member
K

Joined: Sep 2007
Posts: 101
Luxembourg
Oh, true. You are right wink


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