Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Help with installing system

This thread is locked; no one can reply to it. rss feed Print
Help with installing system
Jason Marmon
Member #14,859
January 2013

I'm trying to install the system in order to use timers in my program, but I'm unsure of what the second argument is. According to the documentation, this is the function:
[code]
al_install_system(version, (*atexit_ptr)(void (*)(void)
[/code]
I know the first argument should be ALLEGRO_VERSION_INT, but what does (*atexit_ptr)(void (*)(void) even mean??

Thomas Fjellstrom
Member #476
June 2000
avatar

Its the crazy syntax used to declare pointers to functions.

In this case you can use NULL or atexit (which is a libc function).

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Jason Marmon
Member #14,859
January 2013

oops, wrong code tags, sorry bout that
and thanks for the reply, NULL worked

Trent Gamblin
Member #261
April 2000
avatar

I'd be careful with that. I did that once and on Windows when the program exited, if it was using ALLEGRO_FULLSCREEN_WINDOW the taskbar would be gone. It's a caveat in the A5 Windows port.

EDIT: I mean using NULL. Using atexit is fine.

Jason Marmon
Member #14,859
January 2013

in that case, would you mind explaining how to use atexit? I'm not quite sure how to implement it

Thomas Fjellstrom
Member #476
June 2000
avatar

using the function name without the brackets or arguments will evaluate to the function's address. That is, its exactly what al_install_system wants, a function pointer.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Phrasz
Member #10,091
August 2008

You can always look at the basics:
http://www.maths.cam.ac.uk/undergrad/catam/ccatsl/manual/node50.html

(and then follow up with his link on pointer arguments)

Aikei_c
Member #14,871
January 2013
avatar

It's strange that nobody else mentioned that, but why don't you just use al_init()?

Jason Marmon
Member #14,859
January 2013

Weird, I have that in the code already...I didn't know al_init() also installs the system.

Go to: