|
install_allegro() error |
Curtis Mackie
Member #5,115
October 2004
|
This is the install_allegro line: install_allegro(SYSTEM_AUTODETECT, &errno, stabilize_before_exit); this is the exit function int stabilize_before_exit (void) { allegro_exit(); return 0; } Currently this is just getting things set up properly, I haven't actually started anything real yet... Anyway, the error I'm getting is invalid conversion from `int (*)()' to `int (*)(void (*)())' according to Dev-C++, on the install_allegro line. Anyone know what's going on? |
ReyBrujo
Moderator
January 2001
|
Remove the void inside your argument list. -- |
Curtis Mackie
Member #5,115
October 2004
|
didn't help |
HoHo
Member #4,534
April 2004
|
You don't have to call allegro_exit manually. What you are trying to do is actually done by allegro automatically __________ |
Curtis Mackie
Member #5,115
October 2004
|
thanks for the tip, but it still didn't help |
ReyBrujo
Moderator
January 2001
|
Have you declared the function before using it in the callback? -- |
Curtis Mackie
Member #5,115
October 2004
|
the function is the first line in the source file, I've tried it before and after #include <allegro.h> sorry, I'm not entirely sure what you mean by "before using it in the callback" |
HoHo
Member #4,534
April 2004
|
#include <allegro.h> int stabilize_before_exit () { allegro_exit(); return 0; } int main(int argc, char* argv[]){ install_allegro(SYSTEM_AUTODETECT, &errno, stabilize_before_exit); return 0; } END_OF_MAIN() gcc -w -Wall helloworld.c `allegro-config --libs` I get zero errors or warnings __________ |
BAF
Member #2,981
December 2002
|
Uhm....... as far as I know the last argument should point to atexit... that tells allegro what to call to register its own exit callback. Hence the void (*) error, because atexit takes a void*. [edit] docs said: The `errno_ptr' and `atexit_ptr' parameters should point to the errno variable and atexit function from your libc: these are required because when Allegro is linked as a DLL, it doesn't have direct access to your local libc data. `atexit_ptr' may be NULL, in which case it is your responsibility to call allegro_exit() manually. Example: install_allegro(SYSTEM_AUTODETECT, &errno, atexit); Yep. So, if you want your own function called at the end, run atexit(stabilize_before_exit); in your main. |
Curtis Mackie
Member #5,115
October 2004
|
oh I see... sorry I misunderstood that feature. Okay, I got it now. |
HoHo
Member #4,534
April 2004
|
Quote: because atexit takes a void*. No docs said: #include <stdlib.h> int atexit(void (*func)(void)); __________ |
BAF
Member #2,981
December 2002
|
A void * as in avoid function pointer. |
|