无法解析函数"assert"
Function "assert" could not be resolved
我正在尝试编写一个简单的代码来测试"创建函数",但是当我使用assert
时出现此错误:无法解析函数断言。
这是我的代码:
#include "Participant.h"
#include "ParticipantValidator.h"
#include <assert.h>
void testCreateParticipant()
{
Participant part(1, "Corina", "Marin", 5);
assert(part.getId() == 1);
assert(part.getScore() == 5);
assert(part.getName() == "Corina");
assert(part.getFamilyName() == "Marin");
}
没有函数assert()
。它是一个宏。您可能包含了错误的 assert.h 版本,或者在您之前包含的某个文件中有一个在 assert.h 中被评估为包含保护的#define
。
- 检查您真正包含的包含文件(包括 absulote 路径)。
- 尝试在没有其他头文件的情况下在示例中使用
assert
。
在C++中,你应该#include <cassert>
而不是#include <assert.h>
。
相关文章:
- "error: no matching function for call to"构造函数错误
- 什么时候调用组成单元对象的析构函数
- 继承函数的重载解析
- 为什么随机数生成器不在void函数中随机化数字,而在main函数中随机化
- C++模板来检查友元函数的存在
- 递归函数计算序列中的平方和(并输出过程)
- 对RValue对象调用的LValue ref限定成员函数
- 我关于函数"Assert"的C++代码有问题
- assert() 在发布模式下充当标识函数吗?
- 如何编写一个接受如下断言消息的自定义断言函数:assert(false) << "assertio
- 能够使用debug.assert()函数需要什么
- 如何使用assert函数
- assert和静态assert函数的使用
- assert()函数未在反汇编中显示
- 在 Xcode [c++] 中在断言 (assert.h) 中定义 lambda 时,为类似函数的宏调用提供过多参数会导
- C++中的函数assert()崩溃
- Assert()函数抛出一个错误——操作符有问题
- 如何避免CRT对话框与assert(.)函数
- assert函数如何在失败时返回文件名和代码行
- 无法解析函数"assert"