Search code examples
cucontext

makecontext producing void value?


My issue concerns this line:

    int f = makecontext( &threadList[ numThreads ].context

My program compiles without error without the assignment operation, but does not work at all. The line appears to do nothing. When I add "int f =" the compiler gives me the error:

my_pthread.c:41:10: error: void value not ignored as it ought to be

I don't understand how this is happening, since ucontext should always return 0 or -1.

Any help is appreciated.


Solution

  • The makecontext function is declared as:

    void makecontext(ucontext_t *ucp, void (*func)(), int argc, ...);
    

    It returns no value, so you can't assign the result of the function to anything.