开发者

Assert won't display the error message

I'm having a weird problem with assert in Visual C++ 2005. I've tried 开发者_运维问答to introduce asserts into my program and no matter what asserts I try to use (assert() or BOOST_ASSERT_MSG) it gives the exact same error message which tells me nothing other than that a debug error occurred.

Debug Error!

Program: ...

This application has requested the Runtime to terminate it in an unusual way. Please contact the support team for more information.

(Press Retry to Debug the application)

Here's the boost assertion that I'm using

BOOST_ASSERT_MSG(deathRow.size() >= 3, "There are less than 3 blocks being deleted!");

And yes, it gives the exact same error message as:

assert(deathRow.size() >= 3 && "There are less than 3 blocks being deleted");

Nondescript error happens, no matter what project I'm using, new or old.

I have no idea why. I know I used asserts before in another program and didn't have this problem. Help would be appreciated.


If you use Microsoft's _ASSERTE macro (note the E for Expression) then the message will also appear in assert dialog.

The reason both versions of ASSERT exist is that both have advantages and disadvantages and you get to choose which you want.

  • _ASSERTE gives better diagnostics but results in slightly bigger binaries (since the textual representation of the expression must be included in the binary)
  • _ASSERT give less information in the assert dialog but results in smaller binaries.

Since both flavours only produce code in debug build I tend to always use _ASSERTE because the size of the binary is hardly effected and doesn't matter much in debug builds.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜