Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » install_allegro() error

Credits go to BAF for helping out!
This thread is locked; no one can reply to it. rss feed Print
install_allegro() error
Curtis Mackie
Member #5,115
October 2004
avatar

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
avatar

Remove the void inside your argument list.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Curtis Mackie
Member #5,115
October 2004
avatar

didn't help

HoHo
Member #4,534
April 2004
avatar

You don't have to call allegro_exit manually. What you are trying to do is actually done by allegro automatically :)

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Curtis Mackie
Member #5,115
October 2004
avatar

thanks for the tip, but it still didn't help

ReyBrujo
Moderator
January 2001
avatar

Have you declared the function before using it in the callback?

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Curtis Mackie
Member #5,115
October 2004
avatar

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
avatar

#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 ::)

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

BAF
Member #2,981
December 2002
avatar

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
avatar

oh I see... sorry I misunderstood that feature. Okay, I got it now.

HoHo
Member #4,534
April 2004
avatar

Quote:

because atexit takes a void*.

No

docs said:

#include <stdlib.h>

int atexit(void (*func)(void));

This function places the specified function func on a list of functions to be called when exit is called. These functions are called as if a last-in-first-out queue is used, that is, the last function registered with atexit will be the first function called by exit.
At least 32 functions can be registered this way.

http://www.delorie.com/djgpp/doc/libc/libc_52.html

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

BAF
Member #2,981
December 2002
avatar

A void * as in avoid function pointer.

Go to: