You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

__assert函数的来源及规定其的标准咨询

glibc中__assert函数的标准依据疑问

在阅读glibc源码时,在assert.h中发现如下注释与声明:

/* The following is not at all used here but needed for standard
   compliance.  */
extern void __assert (const char *__assertion, const char *__file, int __line)
     __THROW __attribute__ ((__noreturn__));

请问是哪项标准规定了__assert函数?我在POSIX、C标准、git提交历史、网络及本站中均未找到相关信息。


  • __assert并非POSIX或C标准直接规定的函数,它是glibc为兼容旧版BSD标准(尤其是4.3BSD)保留的符号。
  • 早期BSD系统将__assert定义为断言失败后的处理入口,glibc为保证依赖该符号的旧程序能正常运行,才保留了这个声明,即便当前代码里并未直接使用它。
  • 这类以下划线开头的函数属于实现定义的接口,标准不会强制规定,注释里提到的“standard compliance”实际是指遵循历史兼容标准,而非现行的C或POSIX标准。

内容的提问来源于stack exchange,提问作者KamilCuk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 22:52:01