c - makecontext 产生无效值?

标签 c ucontext

我的问题与这一行有关:

    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/

相关文章:

c - 在没有大括号的单语句 block 之前制作 clang 格式断行

c - 这种类型的 GUI 是如何制作的?

c++ - 为什么 ucontext 有这么高的开销?

c - 实现用户级线程库——从 makecontext 返回值

c - valgrind 错误和 ucontext。为什么是 "Use of uninitialised value of size 8"?

c - 为什么我的函数没有运行并出现无效内存错误?

c - C中的循环。程序中的第一个循环不起作用并且是无限的

c - 在 C 中初始化 2D/3D 数组的简写方法?

c++ - C/C++ time.h,错误的时间打印出来,时间的比较

c - 实现用户级线程库但代码不断出现段错误,有什么想法吗?