I'm doing a thread library (changing context with uncontext.h). My function is of type void, and I can't return. But even if I do not return, this warning appears when compiling:
dccthread.c: In function ‘dccthread_init’:
dccthread.c:184:1: warning: ‘noreturn’ function does return [enabled by default]
}
This is a simplified code of the function (without some details):
void dccthread_init(void (*func), int param) {
int i=0;
if (gerente==NULL)
gerente = (dccthread_t *) malloc(sizeof(dccthread_t));
getcontext(&gerente->contexto);
gerente->contexto.uc_link = NULL;
gerente->contexto.uc_stack.ss_sp = malloc ( THREAD_STACK_SIZE );
gerente->contexto.uc_stack.ss_size = THREAD_STACK_SIZE;
gerente->contexto.uc_stack.ss_flags = 0;
gerente->tid=-1;
makecontext(&gerente->contexto, gerente_escalonador, 0);
if (principal==NULL)
principal = (dccthread_t *) malloc(sizeof(dccthread_t));
getcontext(&principal->contexto);
principal->contexto.uc_link = NULL;
principal->contexto.uc_stack.ss_sp = malloc ( THREAD_STACK_SIZE );
principal->contexto.uc_stack.ss_size = THREAD_STACK_SIZE;
principal->contexto.uc_stack.ss_flags = 0;
makecontext(&principal->contexto, func, 1, param);
swapcontext(&gerente->contexto, &principal->contexto);
}
Note that I don't return anytime. But gcc give me this warning. Does anyone know what's the problem?