CLONE_VM undeclared (first use in this function)
10,081
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
.
Author by
Lawrence Wong
Updated on June 08, 2022Comments
-
Lawrence Wong almost 2 years
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) ;
-
Lawrence Wong about 10 yearsThanks! It worked! May I know what does the _GNU_SOURCE does?
-
Lawrence Wong about 10 yearsNevermind. I found my answer here. stackoverflow.com/questions/5582211/…
-
Lee Duhem about 10 years@LawrenceWong You could find it out by
man 7 feature_test_macros
-
ZeZNiQ over 4 yearsFor me it worked when I put "#define _GNU_SOURCE" then "#include <sched.h>" on top of the source code (above all other #includes).