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.