I have a problem that I can't seem to find the answer to, but I'm willing to bet it's probably a pretty simple one for anybody who has worked with this sort of application setup before.
I'm working with an application that is written in C, but calls a TCL/TK gui to do lots of nice pretty stuff on the screen. However, due to the way that TCL/TK works when run from C, once you've handed over control- you never get it back (i.e. the TCL/TK interpreter handles the application exit, rather than returning to the original main() function).
So basically, there is some code like this:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow){
Tk_Main(1,argv,Tcl_AppInit); // Tcl_AppInit is a function that runs at the start
// All code after this point will never, ever run
return 0; // This return never actually occurs
}
This causes a slight issue. I want to be able to destroy data structures, close files, check for memory leaks, and do other necessary things before the program exits. However, I can't do it after Tk_Main. I have to figure out the hook in the TCL/TK interpreter that runs when it shuts down, then tell that to run my teardown function before quitting.
Anybody know how or where to do this?