Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
makecontext函数中的指针澄清_C_Linux_Unix - Fatal编程技术网

makecontext函数中的指针澄清

makecontext函数中的指针澄清,c,linux,unix,C,Linux,Unix,作为我任务的一部分,我一直在实现一个用户线程库。 我不理解makecontext函数: makecontext(&(mainthread->threadctx),(void(*)(void))start_funct,1,args) (void(*)(void))start_funct的确切含义是什么?为什么我要这样写呢? 我就不能把它写下来吗 makecontext(&(mainthread->threadctx),start_funct,1,args) ? 请耐

作为我任务的一部分,我一直在实现一个用户线程库。 我不理解
makecontext
函数:

makecontext(&(mainthread->threadctx),(void(*)(void))start_funct,1,args)
(void(*)(void))start_funct
的确切含义是什么?为什么我要这样写呢? 我就不能把它写下来吗

makecontext(&(mainthread->threadctx),start_funct,1,args) ?
请耐心等待,我还不习惯使用指针:)

void(*)(void)
的意思是“指向不带参数并返回
void
的函数的指针”

因此,
(void(*)(void))start_funct
正在将
start_funct
(我们可以假设它是某种函数指针)`转换为上述类型。(有一种方法可以帮助你做到这一点,直到你对阅读声明感到更舒服为止)


您必须这样写,因为
start\u funct
的签名不是
void start\u funct(void)
,因此需要强制转换。

注意:
makecontext
实际上需要一个
void(*)(
),指向函数的指针,该函数接受未指定数量的参数并返回
void
@Jon谢谢!谢谢你的在线工具,会很方便的。