79243641

Date: 2024-12-02 10:16:49
Score: 0.5
Natty:
Report link

Quick answer

if you want to use unshare() you should include sched.h, as you did

 #define _GNU_SOURCE
 #include <sched.h>

Where is 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.

What is _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 ...

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Niclas