are C functions declared in headers guaranteed to be in the global namespace as well as std?

后端 未结 3 543
无人及你
无人及你 2020-12-09 17:29

So this is something that I\'ve always wondered but was never quite sure about. So it is strictly a matter of curiosity, not a real problem.

As far as I understand,

3条回答
  •  天涯浪人
    2020-12-09 18:19

    At the present time, no. In fact, even though the code will work with every compiler I now of, it's really not supposed to work at all -- #includeing one of the c* headers is only supposed to give you access to the names inside of namespace std.

    Since implementation of this was such a pain (getting it right essentially required duplicating the entire C library as a C++ library in the right namespace), in C++ 0x they've changed the requirements a bit -- your code is now allowed to work, though (at least if memory serves) it's still not required to work.

提交回复
热议问题