_GNU_SOURCE and __USE_GNU

前端 未结 2 459
清酒与你
清酒与你 2020-12-01 10:32

I want to use CPU_SET, which is a glibc linux-specific macro that should be defined in sched.h The manpage clearly states that _GNU_SOURCE

相关标签:
2条回答
  • 2020-12-01 11:22

    _GNU_SOURCE is the only one you should ever define yourself. __USE_GNU is defined internally through a mechanism in features.h (which is included by all other glibc headers) when _GNU_SOURCE is defined, and possibly under other conditions. Defining or undefining __USE_GNU yourself will badly break the glibc headers.

    0 讨论(0)
  • 2020-12-01 11:24

    you have to define_GNU_SOURCE before anything else. This snippet works here:

    #define _GNU_SOURCE
    #include <sched.h>
    
    
    int main()
    {
        cpu_set_t set;
        CPU_SET(0, &set);
        return 0;
    }
    
    0 讨论(0)
提交回复
热议问题