Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CLONE_VM undeclared (first use in this function)

Tags:

c

linux

clone

I am using the clone feature in linux c.

However, I encountered the error CLONE_VM undeclared (first use in this function) when I tried to compile my code.

I went to google for solutions and one of the site mentioned that #include <sched.h> must be included inside the code. I have already included #include <sched.h> in my code but the compilation error still persists.

Any help? :)

int c = clone(child,p+STACKSIZE-1,CLONE_VM|SIGCHLD,NULL) ;
like image 366
Lawrence Wong Avatar asked Mar 17 '14 08:03

Lawrence Wong


1 Answers

Add the following lines to the beginning of your code

   #define _GNU_SOURCE             /* See feature_test_macros(7) */
   #include <sched.h>

You could find out which header files and/or macros are needed by

  • man 2 syscall_name
  • man 3 library_function_name

By the way, the implication of _GNU_SOURCE and more could be find out by man 7 feature_test_macros.

like image 52
Lee Duhem Avatar answered Nov 14 '22 21:11

Lee Duhem