if you want to use unshare() you should include sched.h, as you did
#define _GNU_SOURCE
#include <sched.h>
unshare()?The unshare()declaration is located in <bits/sched.h>, You can only find an external definition there because unshare()is a system call that depends on os version. You cannot include <bits/sched.h> directly.
_GNU_SOURCE_GNU_SOURCE is a macro that enables a full set of glibc extensions.
if you don't want to explicitly add this #define _GNU_SOURCE. you can instead use the following flag when compiling with gcc
gcc -D_GNU_SOURCE ...