c++ - Qt 中是否有与 MFC VERIFY() 等效的函数?

标签 c++ qt mfc assertions

Qt 有 Q_ASSERT,它相当于 MFC ASSERT(),但 MFC 也有 VERIFY()宏,其行为与调试中的 ASSERT() 相同,但发布除外:

In the Release version of MFC, VERIFY evaluates the expression but does not print or interrupt the program. For example, if the expression is a function call, the call will be made.

Qt 是否有 VERIFY() 的等效项?

最佳答案

它在 Qt 中缺失,但应该很容易制作您自己的:

#if !defined(VERIFY)
# if !defined(QT_NO_DEBUG)
#  define VERIFY Q_ASSERT
# else
#  define VERIFY(expr)  \
    do                    \
    {                     \
        (void) (expr);    \
    } while (0)
# endif
#endif

关于c++ - Qt 中是否有与 MFC VERIFY() 等效的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18712810/

相关文章:

c++ - 为什么这个 C++ 代码在不同的编译器上给出不同的输出?

c++ - qt 防止 qdialog/window 随 mainwindow 一起移动

c++ - 在 Windows 上首次安装 Qt 5

c++ - 如何使用 vector 执行数组计算?

c++ - 使用 strtok() 解析文本文件

c++ - 如何使 QPushButton 可按下回车键?

c++ - 从外部代码调用时,CMDIFrameWnd::MDIGetActive 返回 null

c++ - 我无法加载带有 "LoadImage"的图片并在对话框中绘制

c++ - 在 C++ 中搜索 CString

C++ fstream - 无法使用二进制格式从文件中读取