问题
I've implemented a C++ Exception and throw this exception on errors without catching it. In linux I do see the exception text ("what") on console and the application exists. This is my expected behaviour.
On windows (compiled with Visual C++ 2015) however a popup window opens and states a generic error. I do not see the exception message on console or anywhere else. Is it possible to log thrown/uncaught exceptions to console/stdout (or stderr) on Windows, too?
Thank you
回答1:
Throwing an uncaught exception terminates your program. Your Linux toolchain is being very kind by showing the message anyway; it's certainly not required to do so. This termination counts as a crash, hence the popup window.
Put a try
/catch
pair in main
to safely catch all otherwise-unhandled exceptions. This won't help you with construction of your globals, though.
来源:https://stackoverflow.com/questions/38588305/visual-c-exception-not-shown-in-console