Leo*_*eon 3 c++ namespaces std errno
为了让我的代码更符合C++风格而不是C风格,我想替换errno为std::errno,并替换include <errno.h>为include <cerrno>.
令我惊讶的是,这些都不是std::errno!
众所周知,许多 C 事物都有 C++ 等价物。举例来说:
在 c-source.c 中,我们通常这样编码:
#include <string.h>
print( strerro(1) );
Run Code Online (Sandbox Code Playgroud)
在c++source.cpp中,我们可以这样做:
#include <cstring>
std::cout << std::strerro(1);
Run Code Online (Sandbox Code Playgroud)
为什么存在却不std::errno存在std::strerro?