-
atexit not running?
I'm trying to set up a shutdown function to delete a scene tree in glut. I put the atexit call at the beginning of main:and the function itself looks like:
Code:
void shutDown() {
printf("shutting down...\n");
delete root;
}
This seems like it should run to me, but I don't see anything when the program ends. What am I doing wrong?
-
what's going on? is the program just 'dissapearing'? if so, you may need to put something there to stop execution (like an input statement)
you may need to stop the program with the exit() function.
I would probably avoid using atexit though - it makes for spagetti code. if you need functionality like that put it in a class (if you're using C++)
-
Where I'm sitting, atexit() returns a value - what does it return for you?
-
major_small:
The program is giving the "press any key etc etc" thing before closing down the window, so I assume I'm getting everything that's been sent to stdout. I have to use atexit because I'm using glut to make this program, which uses a callback system and ends execution on its own at some undetermined point.
salem:
atexit returns 0, msdn says that's good times.
-
>> The program is giving the "press any key etc etc" thing before closing down the window
Then, the function given to atexit really ought to be called after this... Perhaps a more reliable test would be to print something to a file in your shutDown function (so that it persists once the window closes). Or, run your program from the command line.