The role of #define _XOPEN_SOURCE in Linux programming

Source: Internet
Author: User
Tags posix

Misunderstanding
#define _xopen_source
It's definitely not a simple macro definition.
It is an integral part of making the program conform to the system environment

Concept
The functions implemented by GLIBC in all or part of the specification are:
1.ISO C:C Language International standard.
2.POSIX: ISO/IEC 9945 (aka IEEE 1003) standard for the operating system.
3.Berkeley Unix:bsd and SunOS.
4.svid:v System Interface Description.
5.xpg:the X/open Portability Guide.

program, in order to achieve the above functions need to define the corresponding macro. As a second functional POSIX, _posix_source should be defined. Similar to _bsd_source, _svid_source, _xopen_source.
Other words:
#define _xopen_source
is to be able to use 5. The X/open portability Guide features.

[Practical Method]
There are two ways to use the above five functions:
1) specified in the CC command, such as: cc-d _posix_source file.c
2) Set the first line of the source program to: # define _posix_source 1

[What is _xopen_source? ]
Translation into Chinese is very lame, the original English interpretation is as follows:
Macro: _xopen_source
If You define this macro, functionality described in the X/open Portability Guide is included. This was a superset of the posix.1 and POSIX.2 functionality and in fact _posix_source and _posix_c_source are Automaticall Y defined.
As the unification of all unices, functionality only available in BSD and SVID are also included.
IF the macro _xopen_source_extended is also defined, even more functionality is available. The Exa functions would make

The role of #define _XOPEN_SOURCE in Linux programming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.