断言未从发布版本中编译出来
我已经告诉 VC++ 在发布模式下编译我的程序,但assert() 语句仍然会触发。我认为应该从发布版本中编译断言以提高性能。这是怎么回事?我还需要设置一些其他设置来跳过编译它们吗?
I've told VC++ to compile my program in release mode, yet the assert() statements still fire. I thought assertions were supposed to be compiled out of release builds for performance. What's going on? Is there some other setting I need to set skip compiling them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查您正在定义哪个预处理器符号。调试版本通常会定义
_DEBUG
,发布版本通常会定义NDEBUG
。当定义NDEBUG
时,断言通常会被关闭。Check which preprocessor symbold you're defining. A Debug build would normally define
_DEBUG
, and a Release build would normally defineNDEBUG
. Assertions would normally be switched off whenNDEBUG
is defined.在调试器下打开应用程序。当断言对话框启动时进行调试->中断。查看触发断言的源文件。现在查看该文件的构建设置。如果设置看起来正确并且您正在加载发行版本,请在编译器命令行上设置 /P 和 /d1PP 以显示错误的 #define 来自何处。
马丁
Open the app under the debugger. Do debug->break when the assertion dialog is up. Look at the source file where the assert is firing. Now look at the build settings of that file. If the settings seem right and you are loading the release version, set /P and /d1PP on the compiler command line to reveal where the errant #define is coming from.
Martyn