在使用errno
时,我曾经读到过这样的话
It is important to include
errno.h
rather than providing your ownextern int errno
, sinceerrno
is implemented in a thread-safe manner that is more than just a simple globalint
.
线程安全方式如何影响#include
和extern
之间的区别?
最佳答案
重要的不是 extern 还是 #include
errno 在 header 中定义为
int* _errno(void);
#define errno (*_errno())
每个线程在其自己的地址空间中都有自己的错误号
关于c - 将外部变量导入本地时, `#include` 和 `extern` 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9956768/