Gamestudio Links
Zorro Links
Newest Posts
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
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, Aku_Aku, 1 invisible), 579 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: how define callback function for 3DGS? [Re: frankjiang] #466288
06/06/17 09:20
06/06/17 09:20
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
your argument list must match when calling!

Code:
void populate_array(int * array, int arraySize, void * getNextValue)
{
	int i;
	for(i = 0; i < arraySize; i++)
	{
		int TempFunction(int a); // temporary function
		TempFunction = getNextValue; // set function pointer
		
		array[i] = TempFunction(i); // execute function
	}
}



Visit my site: www.masterq32.de
Re: how define callback function for 3DGS? [Re: MasterQ32] #466293
06/06/17 12:38
06/06/17 12:38
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
thank you for your answer!
but i want to use this code likes:
Code:
void PrintfText(int value) 
{
    printf("Hello World %d!/n",value);
}

void CallPrintfText(void (*callfuct)(int),int value)
{
    callfuct(value);
}

int main()
{
    CallPrintfText(PrintfText);
    return 0;
}


Last edited by frankjiang; 06/06/17 12:39.

development 3d game is interesting!
Re: how define callback function for 3DGS? [Re: frankjiang] #466295
06/06/17 13:19
06/06/17 13:19
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
as you've seen in my example, you have to use that little workaround.
Code:
void PrintfText(int value) 
{
    printf("Hello World %d!/n",value);
}

void CallPrintfText(void * callfuct,int value)
{
    void func(int);
    func = callfunct;
    func(value);
}

int main()
{
    CallPrintfText(PrintfText);
    return 0;
}


I don't think there's another way using lite-c.


POTATO-MAN saves the day! - Random
Re: how define callback function for 3DGS? [Re: Kartoffel] #466300
06/07/17 02:09
06/07/17 02:09
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
Code:
#include <acknex.h>
#include <default.c>
void PrintfText(int value) 
{
    printf("Hello World n%d!",value);
}

void CallPrintfText(void * callfuct,int value)
{
    void func(int);
    func = callfunct;
    func(value);
}

int main()
{
    CallPrintfText(PrintfText);
    return 0;
}


this code will be show"callfuct undeclared idenitifier"


development 3d game is interesting!
Re: how define callback function for 3DGS? [Re: frankjiang] #466301
06/07/17 05:40
06/07/17 05:40
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Because there's a typo in the first parameter ("callfuct" instead of "callfunct").


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: how define callback function for 3DGS? [Re: Superku] #466306
06/07/17 12:04
06/07/17 12:04
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
so do you know how do it?


development 3d game is interesting!
Re: how define callback function for 3DGS? [Re: frankjiang] #466312
06/08/17 00:51
06/08/17 00:51
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
Superku mean this :



void CallPrintfText(void * callfuct,int value)
{
void func(int);
func = callfunct;
func(value);
}

its not the same name just correct it like this :


Code:
#include <acknex.h>
#include <default.c>
void PrintfText(int value) 
{
    printf("Hello World n%d!",value);
}

void CallPrintfText(void * callfunct,int value)
{
    void func(int);
    func = callfunct;
    func(value);
}

int main()
{
    CallPrintfText(PrintfText,50);
    return 0;
}


Re: how define callback function for 3DGS? [Re: Dico] #466314
06/08/17 05:29
06/08/17 05:29
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
Thank you very much.


development 3d game is interesting!
Re: how define callback function for 3DGS? [Re: frankjiang] #466325
06/08/17 16:08
06/08/17 16:08
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
You're welcome laugh

Page 2 of 2 1 2

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