开发者

Console is intercepting all my assert messages

开发者 https://www.devze.com 2023-03-17 08:53 出处:网络
I have a simple assertion macro that prints 开发者_开发问答out a message. This usually works when the application is not a console application (i.e. I get a nice dialog that pops up, and has the expre

I have a simple assertion macro that prints 开发者_开发问答out a message. This usually works when the application is not a console application (i.e. I get a nice dialog that pops up, and has the expression including the message at which point I can hit retry to debug) but when it is, the console intercepts all the messages. This becomes annoying when the console hides behind the IDE and I have to fish it out, then go back to the assertion dialog, and hit retry to debug.

Is there any way to stop it from intercepting the messages so that the dialog that pops up has all the info.

The macro is this:

#define MyAssert(_Exp, _Msg) assert(_Exp && _Msg)

EDIT: Screenshot

Console is intercepting all my assert messages


The CRT attempts to work out where you want assert output to go to based on the type of application. It detects this from the type of the executable (/SUBSYSTEM). However, you can override with _set_app_type so that the CRT acts as if your console app is a Windows app. More likely, you just want to impact assertions and so should call _CrtSetReportMode to change to _CRTDBG_MODE_WNDW

You didn't specify your VS version, but these are availble (with subtle naming differences in VS2003) for all recent versions.

Martyn

0

精彩评论

暂无评论...
验证码 换一张
取 消