S
someone
not sure exactlywhat you're up to here. But
- hiding standard libraries behind macros seems like a bad idea.
For a start it makes reading your code very difficult for other
people.
Ok, you're right... It was just a quick idea, so I didn't have to change
too much... It's/was a bad idea, I can see that now...
- what do you mean "a macro [...] that catches everything"?
(slightly paraphrashing you)
I mean, I have to "catch" whatever causes the program to quit and just
before it would otherwise quit, it has to cleanup and THEN quit (not
before having cleaned up).
As the other poster said calling exit() in a C++ is generally a bad
idea. It certainly precludes destrutors being called. I think the
effect you want could be had by throwing and not catching. This will
bubble all the way upto the top of the program, calling all the
relevent DTORs on the way. Then exiting.
I've googled a bit around... It's completely stupid: I use opengl / GLUT
and it seems, that if someone closes the glut-window, glut will call
exit(0), exit(1) or whatever... I read that freeGLUT however, doesn't
have this behaviour... It's ridiculous, isn't it?
With exit(0) from glut, is there any solution to cleaning up and freeing
memory?
there's something seriuslywrong if they aren't being called when
exceptions are thown!
Even if I figure out how to use exceptions: I think glut is not
"cleanup"-friendly... I can't believe that...
And the OS is not freeing the memory when exit(0) or exit(1) is called?
OS = linux, windows or mac...
post a simple, working program that illustrates your problem.
I'm not fully convinced that exceptions are the solution, so I cannot
show a simple working program yet.
What if the user pushes the "X" to close the glut-window and glut calls
exit() ? I know glut is not the scope of this group, but I hope someone
can clarify, because I'm not completely sure what to do now...