문제

The title say it all. After including <csetjmp>, longjmp and jmp_buf are in the std namespace, but setjmpis 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, and va_start. —end note ]

In other words, it's a macro.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top