了解Ç错误号 [英] Understanding C errno
问题描述
在我的系统错误号
定义为:
int * __error(void);
#define errno (* __error())
我理解错误号
是一个宏,扩展到 * __error()
功能:
I understand errno
is a macro and expands to * __error()
function:
-
我到处找(来源我的系统上),但我无法找到
__错误()
函数的定义,有人可以显示/解释什么会/应该是它的定义是什么?
I searched everywhere (source on my system) but I can't find the definition of the
__error()
function, can someone show/explain what would/should be the definition of it?
如何除权pression 错误号= 0
适用于上述定义(分配 0
一个功能?)?请问错误号= 0
扩展到 * __error()= 0
?
How the expression errno = 0
works with the above definition (Assigning 0
to a function?)? Does errno = 0
expands to * __error() = 0
?
感谢
推荐答案
的 __误差
函数返回一个指向错误号
变量调用线程。在错误号
宏解引用该指针,从而可以在一个两边出现左值等号。
The __error
function returns a pointer to the errno
variable for the calling thread. The errno
macro dereferences that pointer, resulting in an lvalue that can appear on either side of an equals sign.
要回答你的问题:
-
该功能决定的正确地址为特定线程
错误号
变量。每个线程都有自己的。
The function determines the correct address for the
errno
variable for that specific thread. Each thread gets its own.
是的,就变成(* __error())= 0;
这指定 0
来的线程的错误号
变量。
Yes, it becomes (* __error()) = 0;
which assigns 0
to that thread's errno
variable.
这篇关于了解Ç错误号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!