• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

std::assert 发生了什么

用户头像
it1352
帮助5

问题说明

这个答案和大量重复表明我应该使用 #include <c*> 对于我从 C 代码中提取的 C 头文件,我应该用 std::* 调用它们.

This answer and it's multitude of duplicates indicate that I should be using #include <c*> for the C headers that I pull from in C code, and that I should be calling them with std::*.

我一直在这样做,但我注意到一个例外.std::assert 似乎没有被定义,即使我正确地#include .

I have been doing that but I notice an exception. std::assert doesn't seem to be defined, even when I correctly #include <cassert>.

这是怎么回事?这是实施疏忽,还是实际例外?

What's going on here? Is this an implementation oversight, or an actual exception?

正确答案

#1

assert 是一个宏,而不是一个函数.因此,它需要与普通的旧 assert(condition) 一起使用.

assert is a macro, not a function. Hence, it needs to be used with plain old assert(condition).

这是一个支持链接:http://en.cppreference.com/w/cpp/错误/断言.

这篇好文章是转载于:编程之路

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 编程之路
  • 本文地址: /reply/detail/tanhcakfbh
系列文章
更多 icon
同类精品
更多 icon
继续加载