Re: [AD] version check in allegro_init

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Tue, 2 Nov 2004 09:06:35 +0100, Hein Zelle <hein@xxxxxxxxxx> wrote:
> If you can think of a way to define a function in a header file only
> _once_, you could put an inline function in the headers that returns the
> version number. You can then call that function from allegro_init and
> compare with the compiled in version numbers. I'm not sure if it's
> technically possible to do this without getting multiple definitions
> of the function, though.

If you declare a function static inline, you can put it in a header.
Or, you could even make allegro_init a static inline funciton in a
header:

static inline int allegro_init()
{
    if(ALLEGRO_VERSION != get_allegro_version())
    {
        sprintf(allegro_error, "Allegro version mismatch (%i in
header, %i in lib)", ALLEGRO_VERSION, get_allegro_version());
        return !0;
    }

    return install_allegro(SYSTEM_AUTODETECT, &errno, atexit);
}

This, where get_allegro_version is built into the lib.

- Kitty Cat




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/