문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top