Gamestudio Links
Zorro Links
Newest Posts
freewhyblogelsewhere
by 9489cpjf. 06/03/24 06:06
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,301 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19056 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Function pointer bug #389723
12/17/11 14:43
12/17/11 14:43
Joined: Aug 2003
Posts: 902
Van Buren, Ar
Gordon Offline OP
User
Gordon  Offline OP
User

Joined: Aug 2003
Posts: 902
Van Buren, Ar
the following code shows the bug. It should work in all test cases.. gets a compile error...
Code:
#include <acknex.h>

#define PRAGMA_POINTER

typedef struct {
	int b;
	void func1(int a);
} teststruct;

teststruct gts;

void testfunc(teststruct* ts)
{
	teststruct lts;
	
	lts.b = ts->b;
	lts.func1 = ts->func1;
	gts.b = ts->b;
	gts.func1 = ts->func1;
	
	ts->func1(ts->b);
	
	gts.func1(lts.b);
	
	lts.func1(lts.b);
}

void dummyfunc(int a)
{
	return;
}

void main(void)
{
	teststruct ts;
	
	ts.b = 1;
	ts.func1 = dummyfunc;
	
	testfunc(&ts);p
	
}



tested with 8.1 through 8.3 all fail


Our new web site:Westmarch Studios
Re: Function pointer bug [Re: Gordon] #389741
12/17/11 17:44
12/17/11 17:44
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Structs in Lite-C are not supposed to have member functions.
However it's possible to workaround by using a void* pointer in the struct and for execution a temporary function pointer of correct type where you assign the struct's void* pointer to.

Re: Function pointer bug [Re: FBL] #389743
12/17/11 17:54
12/17/11 17:54
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
wouldn´t it be easier to store the function name + arguments in as a string?
And then use engine_gescript(char* ) to call it?

That was the idea for my Editor to give Entities an Action at runtime.


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Function pointer bug [Re: FBL] #389861
12/19/11 06:13
12/19/11 06:13
Joined: Aug 2003
Posts: 902
Van Buren, Ar
Gordon Offline OP
User
Gordon  Offline OP
User

Joined: Aug 2003
Posts: 902
Van Buren, Ar
It is not a member pointer but the way that lite-c handles function pointers. If you run the code you will see that it works with the struct pointer that is passed in but not with the non pointer versions.


Our new web site:Westmarch Studios

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