learn more...In glibc, there are a set of feature selection macros that are used to select which standards you wish glibc to comply with. Standards sometimes conflict, and so glibc allows you to select exactly which set of standards (formal, de jure, and informal, de facto) with which to comply, fully or partially. These macros are technically called feature test macros. You need to be aware of these macros because the default set of macros defined does not provide all the functionality of glibc. A few mechanisms are not available with the default feature set selected; we document the required feature macros to use each of these mechanisms. The feature test macros are designed to specify with what standards (de jure or de facto), and in some cases precisely which versions of those standards, glibc should comply. This compliance often includes not defining functions and macros beyond what is specified by a standard for header files that are themselves defined by that standard. That means that an application written to conform with a standard can define its own functions and macros without conflicting with extensions not defined by that standard. The feature test macros do not guarantee that your application is fully compatible with the set of standards specified by the set of macros you define. Setting the feature test macros may find some use of nonportable extensions, but it will not show, for example, use of header files that are entirely unspecified by the standard. The macros are defined in the system header file feature.h, which you should not include directly. Instead, all other header files that might be affected by the contents of feature.h include it. The default set of feature macros if none are defined is _SVID_SOURCE=1,_BSD_SOURCE=1,_POSIX_SOURCE=1, and _POSIX_C_SOURCE=199506L. Each option is described in more detail below, but this essentially translates into "support the capabilities of the 1995 POSIX standard, all standard System V features, and all BSD features that do not conflict with System V features." This default set of feature macros suffices for most programs. When you give gcc the -ansi option, it automatically defines the internal __STRICT_ANSI__ macro, which turns off all the default feature macros. With the exception of the __STRICT_ANSI__ macro, which is special (and which should be set only by the compiler in the context of the -ansi command line option), these feature macros are cumulative; you can define any combination of them. The exact definition of _BSD_SOURCE changes depending on which other feature macros are set (as documented below); the rest are purely cumulative. Some of the feature test macros are defined by various versions of POSIX or other standards, some are common in the industry, and others are strictly limited to glibc.
When the standard set of feature test macros will not suffice, the most commonly useful feature macros to define are _GNU_SOURCE (turn everything on—the easiest solution), _XOPEN_SOURCE=600 (most things you are likely to care about, a subset of _GNU_SOURCE), or _ISOC99_SOURCE (use features from the most recent C standard, a subset of _XOPEN_SOURCE=600). |
||||||||||||||||||||||
Disclaimer
1) E-articles is not responsible for the information contained by this article as well for any and all copyright infringements by authors and writers. E-articles is a free information resource. If you suspect this article for any copyright infringement, please read the terms of service and contact us to investigate the problem.
2) E-articles is not responsible for inaccuracies, falsehoods, or any other types of misinformation this article may contain and will not be liable for any loss or damage suffered by a user through the user's reliance on the information gained here. link to this article |