Visual C++ Exception not shown in console

本小妞迷上赌 提交于 2021-02-20 19:03:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!