我的问题与这一行有关:
int f = makecontext( &threadList[ numThreads ].context
我的程序在没有赋值操作的情况下编译没有错误,但根本无法运行。该行似乎什么都不做。当我添加“int f =”时,编译器给出错误:
my_pthread.c:41:10: error: void value not ignored as it ought to be
我不明白这是怎么发生的,因为 ucontext 应该总是返回 0 或 -1。
感谢任何帮助。
最佳答案
makecontext
函数声明为:
void makecontext(ucontext_t *ucp, void (*func)(), int argc, ...);
它不返回任何值,因此您不能将函数的结果赋值给任何东西。
关于c - makecontext 产生无效值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54837900/