gpt4 book ai didi

c++ - 将 MFC 库移植到 linux 和 ASSERT

转载 作者:行者123 更新时间:2023-11-30 02:49:10 24 4
gpt4 key购买 nike

我有一个普通的 C++ 背景,但是我没有用 MFC 开发任何东西,我遇到了一个我需要使其可移植的 Lib,例如有很多断言调用

void putValue(LPCTSTR lpszValue)
{
ASSERT(AfxIsValidString(lpszValue));
.
.
.
}

MSDN

The most typical use of the ASSERT macro is to identify program errors during development. The argument given to ASSERT should be chosen so that it holds true only if the program is operating as intended. The macro evaluates the ASSERT argument and, if the argument expression is false (0), alerts the user and halts program execution. No action is taken if the argument is true (nonzero).

如果我要将其移植到 GCC 中进行编译,正确的做法是将条件放在 if 语句中并抛出一个异常 ID 表示条件有效吗?

最佳答案

我想你可以简单地:

#ifndef ASSERT
#include <cassert>
#define ASSERT assert
#endif

关于c++ - 将 MFC 库移植到 linux 和 ASSERT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21464818/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com