包含 <csetjmp> 时,为什么 std 命名空间中没有 setjmp? [英] Why isn't setjmp in the std namespace when including <csetjmp>?
问题描述
标题说明了一切.包含
后,longjmp
和jmp_buf
都在std
命名空间中,但setjmp
不是.我在 MinGW4.5 和 MSVC10 上验证了这一点.在查看
标头后,我无法弄清楚这个选择的原因.我一直假设每个 <cheader>
文件都将
包装在 std
命名空间中.
我错了吗?setjmp
特殊情况背后的基本原理是什么?请赐教!
注意:我知道在 C++ 中滥用 setjmp/longjmp 的问题.
setjmp
可以作为宏来实现,所以C++标准在17.6.1.2 [headers]中有这样的规定:><块引用>
在 C 中定义为宏的名称应在 C 中定义为宏C++ 标准库,即使 C 授予实施许可作为函数.[ 注意:在 C 中定义为宏的名称包括如下:assert
、offsetof
、setjmp
、va_arg
、va_end
和va_start
.——结尾说明]
换句话说,它是一个宏.
The title say it all. After including <csetjmp>
, longjmp
and jmp_buf
are in the std
namespace, but setjmp
is not. I verified this on MinGW4.5 and MSVC10. After looking into the <csetjmp>
header, I could not figure out the reason of this choice. I was always assuming that every <cheader>
file is wrapping a <header.h>
in the std
namespace.
Am I wrong ? What's the rationale behind the setjmp
special case ? Please enlighten me !
Note : I'm aware of the issues of misusing setjmp/longjmp in C++.
setjmp
can be implemented as a macro, so the C++ standard has this to say in 17.6.1.2 [headers]:
Names which are defined as macros in C shall be defined as macros in the C++ standard library, even if C grants license for implementation as functions. [ Note: The names defined as macros in C include the following:
assert
,offsetof
,setjmp
,va_arg
,va_end
, andva_start
. —end note ]
In other words, it's a macro.
这篇关于包含 <csetjmp> 时,为什么 std 命名空间中没有 setjmp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!