3

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?

glglgl
  • 89,107
  • 13
  • 149
  • 217
user3242743
  • 1,751
  • 5
  • 22
  • 32

1 Answers1

3

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.

Community
  • 1
  • 1
TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130