2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
OP
Member
|
OP
Member
Joined: Dec 2009
Posts: 128
China
|
thank you for your answer! but i want to use this code likes:
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
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
as you've seen in my example, you have to use that little workaround.
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
OP
Member
|
OP
Member
Joined: Dec 2009
Posts: 128
China
|
#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: Superku]
#466306
06/07/17 12:04
06/07/17 12:04
|
Joined: Dec 2009
Posts: 128 China
frankjiang
OP
Member
|
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
Senior Member
|
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 :
#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;
}
|
|
|
|