我的问题与以下内容有关:
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。
感谢您的帮助。
答案 0 :(得分:2)
makecontext
函数声明为:
void makecontext(ucontext_t *ucp, void (*func)(), int argc, ...);
它不返回任何值,因此您不能将函数的结果分配给任何东西。