Linux编程中 #define _XOPEN_SOURCE的作用
2015-11-27 11:24
197 查看
[误解]
#define _XOPEN_SOURCE
决不是简单的宏定义
它是使程序符合系统环境的不可缺少的部分
[概念]
Glibc 所实现全部或部分规范下的功能有:
1.ISO C: C语言国际标准.
2.POSIX: 操作系统的 ISO/IEC 9945 (aka IEEE 1003) 标准.
3.Berkeley Unix: BSD 和 SunOS.
4.SVID: V 系统接口描述.
5.XPG: The X/Open Portability Guide.
程序中,为了实现上述功能需要定义对应的宏。如第二个功能POSIX,应定义 _POSIX_SOURCE。类似的有 _BSD_SOURCE、_SVID_SOURCE、_XOPEN_SOURCE。
也就是说:
#define _XOPEN_SOURCE
是为了可以使用 5. The X/Open Portability Guide 的功能。
[实用方法]
使用上述五种功能的方法有两种:
1)在cc命令中指定,如:cc -D _POSIX_SOURCE file.c
2)将源程序的第一行设置为:#define _POSIX_SOURCE 1
[_XOPEN_SOURCE是什么?]
翻译成汉语表达很蹩脚,英文原版解释如下:
Macro: _XOPEN_SOURCE
If you define this macro, functionality described in the X/Open Portability Guide is included. This is a superset of the POSIX.1 and POSIX.2 functionality and in fact _POSIX_SOURCE and _POSIX_C_SOURCE are automatically defined.
As the unification of all Unices, functionality only available in BSD and SVID is also included.
If the macro _XOPEN_SOURCE_EXTENDED is also defined, even more functionality is available. The exa functions will make
#define _XOPEN_SOURCE
决不是简单的宏定义
它是使程序符合系统环境的不可缺少的部分
[概念]
Glibc 所实现全部或部分规范下的功能有:
1.ISO C: C语言国际标准.
2.POSIX: 操作系统的 ISO/IEC 9945 (aka IEEE 1003) 标准.
3.Berkeley Unix: BSD 和 SunOS.
4.SVID: V 系统接口描述.
5.XPG: The X/Open Portability Guide.
程序中,为了实现上述功能需要定义对应的宏。如第二个功能POSIX,应定义 _POSIX_SOURCE。类似的有 _BSD_SOURCE、_SVID_SOURCE、_XOPEN_SOURCE。
也就是说:
#define _XOPEN_SOURCE
是为了可以使用 5. The X/Open Portability Guide 的功能。
[实用方法]
使用上述五种功能的方法有两种:
1)在cc命令中指定,如:cc -D _POSIX_SOURCE file.c
2)将源程序的第一行设置为:#define _POSIX_SOURCE 1
[_XOPEN_SOURCE是什么?]
翻译成汉语表达很蹩脚,英文原版解释如下:
Macro: _XOPEN_SOURCE
If you define this macro, functionality described in the X/Open Portability Guide is included. This is a superset of the POSIX.1 and POSIX.2 functionality and in fact _POSIX_SOURCE and _POSIX_C_SOURCE are automatically defined.
As the unification of all Unices, functionality only available in BSD and SVID is also included.
If the macro _XOPEN_SOURCE_EXTENDED is also defined, even more functionality is available. The exa functions will make
相关文章推荐
- Linux系统ImageMagick图片处理
- 解决无法从windows配置的odbc数据源连接到linux下的TimesTen1122。
- archlinux BMC43142网卡无法驱动
- 虚拟机CentOS联网相关配置
- Linux的命令行中一些文本操作技巧的实例分享
- 刚装完archlinux后ifconfig无法使用
- Linux系统中tr命令删除和替换文本字符的基本用法
- linux系统管理之安装操作系统rhel7.1
- linux nc命令常用用法
- Linux 时钟 - 操作系统时钟和硬件时钟
- centos 安装配置 nexus maven私有仓库
- Linux下特殊权限suid和set_gid权限
- Windows和Linux下取得系统时间(毫秒级)
- Linux下的chmod,umask,chown命令
- Linux文件和目录属性
- 在嵌入式Linux系统(OK6410)中移植Boa 服务器
- Linux系统中uniq命令的基本使用教程
- 查看linux文件的命令
- linux创建sftp账号及访问权限
- linux的系统的7个运行级别