在编写网络程序时,会涉及到一些关于BSD系统保留下的结构体和宏定义,关于一切配置在linux系统的/usr/include/features.h文件中,开启项如下:

#ifdef _GNU_SOURCE
# undef  _ISOC99_SOURCE
# define _ISOC99_SOURCE 1
# undef  _POSIX_SOURCE
# define _POSIX_SOURCE  1
# undef  _POSIX_C_SOURCE
# define _POSIX_C_SOURCE        199506L
# undef  _XOPEN_SOURCE
# define _XOPEN_SOURCE  600
# undef  _XOPEN_SOURCE_EXTENDED
# define _XOPEN_SOURCE_EXTENDED 1
# undef  _LARGEFILE64_SOURCE
# define _LARGEFILE64_SOURCE    1
# undef  _BSD_SOURCE
# define _BSD_SOURCE    1
# undef  _SVID_SOURCE
# define _SVID_SOURCE   1
#endif
可以看出只要开启了_GNU_SOURCE的花,大部分的BSD功能可以打开,看看_GNU_SOURCE是否开启有一个测试程序:

#include <iostream>

int main()
{
#ifdef _GNU_SOURCE
  std::cout << "gnu/n";
#else
  std::cout << "non-gnu/n";
#endif
}
只要gcc -D _GNU_SOURCE test.c -o test.o编译生成的text.o文件,运行一下就知道是否开启了

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:1 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐