It's not optimized away - it can't be!
I suspect it's not making it into the object file. Note that a prototype or definition for function must preceed a #pragma function - otherwise you will just get a warning, and noting is emitted to the object file.
A hex view of the LIB file indicates the routine is there. Also I can call it in my programs without any problems... It's only in the one specific situation where it doesn't work....
1) Where the header is used in a program
2) There is no call to any other function in the library.
It is the situation where I just want the enhanced error reporting (exception code, program address, string description in a message box) that's not working. If I reference even one of the functions in the library, it all gets hooked up and works properly and, of course, if I call the function explicitly it works.
It's not really a big deal (like the exception keyword trashing pointers). I can always just call the thing as the first step in my main and winmain functions.... It's just that the #pragma method gets it into the program startup earler in the process... :lol: before I have the chance to make any mistakes.