Pergunta

I am using the function clone() to create threads. The problem is that I am having this error during compilation:

implicit declaration of function ‘clone’ [-Wimplicit-function-declaration]

I included <linux/sched.h>. What can be the problem?

Foi útil?

Solução

Add the following lines at the top of you source file

#define _GNU_SOURCE  
#include <linux/sched.h>        /* or #include <sched.h> */

_GNU_SOURCE is a Feature test macro.

Feature test macros allow the programmer to control the definitions that are exposed by system header files when a program is compiled. In order to be effective, a feature test macro must be defined before including any header files. This can be done either in the compilation command (cc -DMACRO=value) or by #define-ing the macro within the source code before #include-ing any headers.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top