{
    "content": [
        {
            "type": "text",
            "text": "# feature_test_macros (man)\n\n## NAME\n\nfeaturetestmacros - feature test macros\n\n## DESCRIPTION\n\nFeature  test macros allow the programmer to control the definitions that are exposed by sys‐\ntem header files when a program is compiled.\n\n## Sections\n\n- **NAME**\n- **DESCRIPTION** (15 subsections)\n- **STANDARDS**\n- **HISTORY**\n- **NOTES**\n- **EXAMPLES** (1 subsections)\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "feature_test_macros",
        "section": "",
        "mode": "man",
        "summary": "featuretestmacros - feature test macros",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "The  program below can be used to explore how the various feature test macros are set depend‐",
            "ing on the glibc version and what feature test macros  are  explicitly  set.   The  following",
            "shell session, on a system with glibc 2.10, shows some examples of what we would see:",
            "$ cc ftm.c",
            "$ ./a.out",
            "POSIXSOURCE defined",
            "POSIXCSOURCE defined: 200809L",
            "BSDSOURCE defined",
            "SVIDSOURCE defined",
            "ATFILESOURCE defined",
            "$ cc -DXOPENSOURCE=500 ftm.c",
            "$ ./a.out",
            "POSIXSOURCE defined",
            "POSIXCSOURCE defined: 199506L",
            "XOPENSOURCE defined: 500",
            "$ cc -DGNUSOURCE ftm.c",
            "$ ./a.out",
            "POSIXSOURCE defined",
            "POSIXCSOURCE defined: 200809L",
            "ISOC99SOURCE defined",
            "XOPENSOURCE defined: 700",
            "XOPENSOURCEEXTENDED defined",
            "LARGEFILE64SOURCE defined",
            "BSDSOURCE defined",
            "SVIDSOURCE defined",
            "ATFILESOURCE defined",
            "GNUSOURCE defined",
            "/* ftm.c */",
            "#include <stdint.h>",
            "#include <stdio.h>",
            "#include <unistd.h>",
            "#include <stdlib.h>",
            "int",
            "main(int argc, char *argv[])",
            "#ifdef POSIXSOURCE",
            "printf(\"POSIXSOURCE defined\\n\");",
            "#endif",
            "#ifdef POSIXCSOURCE",
            "printf(\"POSIXCSOURCE defined: %jdL\\n\",",
            "(intmaxt) POSIXCSOURCE);",
            "#endif",
            "#ifdef ISOC99SOURCE",
            "printf(\"ISOC99SOURCE defined\\n\");",
            "#endif",
            "#ifdef ISOC11SOURCE",
            "printf(\"ISOC11SOURCE defined\\n\");",
            "#endif",
            "#ifdef XOPENSOURCE",
            "printf(\"XOPENSOURCE defined: %d\\n\", XOPENSOURCE);",
            "#endif",
            "#ifdef XOPENSOURCEEXTENDED",
            "printf(\"XOPENSOURCEEXTENDED defined\\n\");",
            "#endif",
            "#ifdef LARGEFILE64SOURCE",
            "printf(\"LARGEFILE64SOURCE defined\\n\");",
            "#endif",
            "#ifdef FILEOFFSETBITS",
            "printf(\"FILEOFFSETBITS defined: %d\\n\", FILEOFFSETBITS);",
            "#endif",
            "#ifdef TIMEBITS",
            "printf(\"TIMEBITS defined: %d\\n\", TIMEBITS);",
            "#endif",
            "#ifdef BSDSOURCE",
            "printf(\"BSDSOURCE defined\\n\");",
            "#endif",
            "#ifdef SVIDSOURCE",
            "printf(\"SVIDSOURCE defined\\n\");",
            "#endif",
            "#ifdef DEFAULTSOURCE",
            "printf(\"DEFAULTSOURCE defined\\n\");",
            "#endif",
            "#ifdef ATFILESOURCE",
            "printf(\"ATFILESOURCE defined\\n\");",
            "#endif",
            "#ifdef GNUSOURCE",
            "printf(\"GNUSOURCE defined\\n\");",
            "#endif",
            "#ifdef REENTRANT",
            "printf(\"REENTRANT defined\\n\");",
            "#endif",
            "#ifdef THREADSAFE",
            "printf(\"THREADSAFE defined\\n\");",
            "#endif",
            "#ifdef FORTIFYSOURCE",
            "printf(\"FORTIFYSOURCE defined\\n\");",
            "#endif",
            "exit(EXITSUCCESS);"
        ],
        "see_also": [
            {
                "name": "libc",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/libc/7/json"
            },
            {
                "name": "standards",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/standards/7/json"
            },
            {
                "name": "systemdatatypes",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/systemdatatypes/7/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 23,
                "subsections": [
                    {
                        "name": "Specification of feature test macro requirements in manual pages",
                        "lines": 39
                    },
                    {
                        "name": "Feature test macros understood by glibc",
                        "lines": 35
                    },
                    {
                        "name": "__STRICT_ANSI__",
                        "lines": 3
                    },
                    {
                        "name": "_POSIX_C_SOURCE",
                        "lines": 20
                    },
                    {
                        "name": "_POSIX_SOURCE",
                        "lines": 6
                    },
                    {
                        "name": "_XOPEN_SOURCE",
                        "lines": 37
                    },
                    {
                        "name": "_XOPEN_SOURCE_EXTENDED",
                        "lines": 29
                    },
                    {
                        "name": "_LARGEFILE64_SOURCE",
                        "lines": 7
                    },
                    {
                        "name": "_LARGEFILE_SOURCE",
                        "lines": 7
                    },
                    {
                        "name": "_FILE_OFFSET_BITS",
                        "lines": 11
                    },
                    {
                        "name": "_TIME_BITS",
                        "lines": 48
                    },
                    {
                        "name": "_GNU_SOURCE",
                        "lines": 10
                    },
                    {
                        "name": "_REENTRANT",
                        "lines": 17
                    },
                    {
                        "name": "_THREAD_SAFE",
                        "lines": 31
                    },
                    {
                        "name": "Default definitions, implicit definitions, and combining definitions",
                        "lines": 38
                    }
                ]
            },
            {
                "name": "STANDARDS",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 29,
                "subsections": [
                    {
                        "name": "Program source",
                        "lines": 82
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "featuretestmacros - feature test macros\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Feature  test macros allow the programmer to control the definitions that are exposed by sys‐\ntem header files when a program is compiled.\n\nNOTE: In order to be effective, a feature test macro must be  defined  before  including  any\nheader  files.   This  can be done either in the compilation command (cc -DMACRO=value) or by\ndefining the macro within the source code before including any headers.  The requirement that\nthe macro must be defined before including any header file exists because  header  files  may\nfreely  include  one  another.   Thus,  for  example,  in  the  following lines, defining the\nGNUSOURCE macro may have no effect because  the  header  <abc.h>  itself  includes  <xyz.h>\n(POSIX explicitly allows this):\n\n#include <abc.h>\n#define GNUSOURCE\n#include <xyz.h>\n\nSome  feature  test  macros are useful for creating portable applications, by preventing non‐\nstandard definitions from being exposed.  Other macros can be used to expose nonstandard def‐\ninitions that are not exposed by default.\n\nThe precise effects of each of the feature test macros described below can be ascertained  by\ninspecting  the <features.h> header file.  Note: applications do not need to directly include\n<features.h>; indeed, doing so is actively discouraged.  See NOTES.\n",
                "subsections": [
                    {
                        "name": "Specification of feature test macro requirements in manual pages",
                        "content": "When a function requires that a feature test macro is defined, the manual page SYNOPSIS typi‐\ncally includes a note of the following form (this example from the acct(2) manual page):\n\n#include <unistd.h>\n\nint acct(const char *filename);\n\nFeature Test Macro Requirements for glibc (see\nfeaturetestmacros(7)):\n\nacct(): BSDSOURCE || (XOPENSOURCE && XOPENSOURCE < 500)\n\nThe || means that in order to obtain the declaration of acct(2) from  <unistd.h>,  either  of\nthe following macro definitions must be made before including any header files:\n\n#define BSDSOURCE\n#define XOPENSOURCE        /* or any value < 500 */\n\nAlternatively, equivalent definitions can be included in the compilation command:\n\ncc -DBSDSOURCE\ncc -DXOPENSOURCE           # Or any value < 500\n\nNote  that,  as  described below, some feature test macros are defined by default, so that it\nmay not always be necessary to explicitly specify the feature test macro(s) shown in the SYN‐\nOPSIS.\n\nIn a few cases, manual pages use a shorthand for expressing the feature test  macro  require‐\nments (this example from readahead(2)):\n\n#define GNUSOURCE\n#define FILEOFFSETBITS 64\n#include <fcntl.h>\n\nssizet readahead(int fd, offt *offset, sizet count);\n\nThis format is employed when the feature test macros ensure that the proper function declara‐\ntions are visible, and the macros are not defined by default.\n"
                    },
                    {
                        "name": "Feature test macros understood by glibc",
                        "content": "The paragraphs below explain how feature test macros are handled in glibc 2.x, x > 0.\n\nFirst, though, a summary of a few details for the impatient:\n\n•  The macros that you most likely need to use in modern source code are POSIXCSOURCE (for\ndefinitions from various versions of POSIX.1), XOPENSOURCE (for definitions from various\nversions  of  SUS), GNUSOURCE (for GNU and/or Linux specific stuff), and DEFAULTSOURCE\n(to get definitions that would normally be provided by default).\n\n•  Certain macros are defined with default values.  Thus, although one or more macros may  be\nindicated  as being required in the SYNOPSIS of a man page, it may not be necessary to de‐\nfine them explicitly.  Full details of the defaults are given later in this man page.\n\n•  Defining XOPENSOURCE with a value of 600 or greater produces the same effects as  defin‐\ning POSIXCSOURCE with a value of 200112L or greater.  Where one sees\n\nPOSIXCSOURCE >= 200112L\n\nin  the feature test macro requirements in the SYNOPSIS of a man page, it is implicit that\nthe following has the same effect:\n\nXOPENSOURCE >= 600\n\n•  Defining XOPENSOURCE with a value of 700 or greater produces the same effects as  defin‐\ning POSIXCSOURCE with a value of 200809L or greater.  Where one sees\n\nPOSIXCSOURCE >= 200809L\n\nin  the feature test macro requirements in the SYNOPSIS of a man page, it is implicit that\nthe following has the same effect:\n\nXOPENSOURCE >= 700\n\nglibc understands the following feature test macros:\n"
                    },
                    {
                        "name": "__STRICT_ANSI__",
                        "content": "ISO Standard C.  This macro is implicitly defined by gcc(1) when invoked with, for ex‐\nample, the -std=c99 or -ansi flag.\n"
                    },
                    {
                        "name": "_POSIX_C_SOURCE",
                        "content": "Defining this macro causes header files to expose definitions as follows:\n\n•  The value 1 exposes definitions conforming to POSIX.1-1990 and ISO C (1990).\n\n•  The value 2 or greater additionally exposes definitions for POSIX.2-1992.\n\n•  The value 199309L or greater additionally exposes definitions for  POSIX.1b  (real-\ntime extensions).\n\n•  The  value  199506L  or  greater  additionally  exposes  definitions  for  POSIX.1c\n(threads).\n\n•  (Since glibc 2.3.3) The value 200112L or greater additionally  exposes  definitions\ncorresponding to the POSIX.1-2001 base specification (excluding the XSI extension).\nThis  value  also causes C95 (since glibc 2.12) and C99 (since glibc 2.10) features\nto be exposed (in other words, the equivalent of defining ISOC99SOURCE).\n\n•  (Since glibc 2.10) The value 200809L or greater  additionally  exposes  definitions\ncorresponding to the POSIX.1-2008 base specification (excluding the XSI extension).\n"
                    },
                    {
                        "name": "_POSIX_SOURCE",
                        "content": "Defining  this obsolete macro with any value is equivalent to defining POSIXCSOURCE\nwith the value 1.\n\nSince this macro is obsolete, its usage is generally not  documented  when  discussing\nfeature test macro requirements in the man pages.\n"
                    },
                    {
                        "name": "_XOPEN_SOURCE",
                        "content": "Defining this macro causes header files to expose definitions as follows:\n\n•  Defining  with  any  value  exposes definitions conforming to POSIX.1, POSIX.2, and\nXPG4.\n\n•  The value 500 or greater additionally exposes definitions for SUSv2 (UNIX 98).\n\n•  (Since glibc 2.2) The value 600 or greater  additionally  exposes  definitions  for\nSUSv3  (UNIX  03; i.e., the POSIX.1-2001 base specification plus the XSI extension)\nand C99 definitions.\n\n•  (Since glibc 2.10) The value 700 or greater additionally  exposes  definitions  for\nSUSv4 (i.e., the POSIX.1-2008 base specification plus the XSI extension).\n\nIf  STRICTANSI  is  not defined, or XOPENSOURCE is defined with a value greater\nthan or equal to 500 and neither POSIXSOURCE nor POSIXCSOURCE is  explicitly  de‐\nfined, then the following macros are implicitly defined:\n\n•  POSIXSOURCE is defined with the value 1.\n\n•  POSIXCSOURCE is defined, according to the value of XOPENSOURCE:\n\nXOPENSOURCE < 500\nPOSIXCSOURCE is defined with the value 2.\n\n500 <= XOPENSOURCE < 600\nPOSIXCSOURCE is defined with the value 199506L.\n\n600 <= XOPENSOURCE < 700\nPOSIXCSOURCE is defined with the value 200112L.\n\n700 <= XOPENSOURCE (since glibc 2.10)\nPOSIXCSOURCE is defined with the value 200809L.\n\nIn  addition,  defining XOPENSOURCE with a value of 500 or greater produces the same\neffects as defining XOPENSOURCEEXTENDED.\n"
                    },
                    {
                        "name": "_XOPEN_SOURCE_EXTENDED",
                        "content": "If this macro is defined, and XOPENSOURCE is defined, then expose definitions corre‐\nsponding to the XPG4v2 (SUSv1) UNIX extensions (UNIX 95).  Defining XOPENSOURCE with\na value of 500 or more also produces the same  effect  as  defining  XOPENSOURCEEX‐\nTENDED.  Use of XOPENSOURCEEXTENDED in new source code should be avoided.\n\nSince defining XOPENSOURCE with a value of 500 or more has the same effect as defin‐\ning  XOPENSOURCEEXTENDED, the latter (obsolete) feature test macro is generally not\ndescribed in the SYNOPSIS in man pages.\n\nISOC99SOURCE (since glibc 2.1.3)\nExposes declarations consistent with the ISO C99 standard.\n\nEarlier glibc 2.1.x versions recognized an equivalent macro named ISOC9XSOURCE  (be‐\ncause  the  C99 standard had not then been finalized).  Although the use of this macro\nis obsolete, glibc continues to recognize it for backward compatibility.\n\nDefining ISOC99SOURCE also exposes ISO C (1990)  Amendment  1  (\"C95\")  definitions.\n(The primary change in C95 was support for international character sets.)\n\nInvoking the C compiler with the option -std=c99 produces the same effects as defining\nthis macro.\n\nISOC11SOURCE (since glibc 2.16)\nExposes  declarations  consistent with the ISO C11 standard.  Defining this macro also\nenables C99 and C95 features (like ISOC99SOURCE).\n\nInvoking the C compiler with the option -std=c11 produces the same effects as defining\nthis macro.\n"
                    },
                    {
                        "name": "_LARGEFILE64_SOURCE",
                        "content": "Expose definitions for the alternative API specified by the LFS (Large File Summit) as\na \"transitional extension\"  to  the  Single  UNIX  Specification.   (See  \u001b]8;;http://opengroup.org/platform/lfs.html\u001b\\http://open‐\ngroup.org/platform/lfs.html\u001b]8;;\u001b\\.)   The  alternative  API consists of a set of new objects\n(i.e., functions and types) whose names are suffixed with \"64\" (e.g.,  off64t  versus\nofft,  lseek64()  versus  lseek(), etc.).  New programs should not employ this macro;\ninstead FILEOFFSETBITS=64 should be employed.\n"
                    },
                    {
                        "name": "_LARGEFILE_SOURCE",
                        "content": "This macro was historically used to expose certain functions  (specifically  fseeko(3)\nand  ftello(3))  that address limitations of earlier APIs (fseek(3) and ftell(3)) that\nuse long for file offsets.  This macro is implicitly defined if XOPENSOURCE  is  de‐\nfined  with a value greater than or equal to 500.  New programs should not employ this\nmacro; defining XOPENSOURCE as just described or defining FILEOFFSETBITS with the\nvalue 64 is the preferred mechanism to achieve the same result.\n"
                    },
                    {
                        "name": "_FILE_OFFSET_BITS",
                        "content": "Defining this macro with the value 64  automatically  converts  references  to  32-bit\nfunctions and data types related to file I/O and filesystem operations into references\nto  their  64-bit counterparts.  This is useful for performing I/O on large files (> 2\nGigabytes) on  32-bit  systems.   It  is  also  useful  when  calling  functions  like\ncopyfilerange(2) that were added more recently and that come only in 64-bit flavors.\n(Defining this macro permits correctly written programs to use large files with only a\nrecompilation being required.)\n\n64-bit systems naturally permit file sizes greater than 2 Gigabytes, and on those sys‐\ntems this macro has no effect.\n"
                    },
                    {
                        "name": "_TIME_BITS",
                        "content": "Defining  this  macro  with  the value 64 changes the width of timet(3type) to 64-bit\nwhich allows handling of timestamps beyond 2038.  It is closely related to  FILEOFF‐\nSETBITS and depending on implementation, may require it set.  This macro is available\nas of glibc 2.34.\n\nBSDSOURCE (deprecated since glibc 2.20)\nDefining  this  macro with any value causes header files to expose BSD-derived defini‐\ntions.\n\nIn glibc versions up to and including 2.18, defining this macro also causes BSD defin‐\nitions to be preferred in some situations where standards conflict, unless one or more\nof  SVIDSOURCE,  POSIXSOURCE,  POSIXCSOURCE,  XOPENSOURCE,  XOPENSOURCEEX‐\nTENDED,  or  GNUSOURCE  is  defined,  in  which case BSD definitions are disfavored.\nSince glibc 2.19, BSDSOURCE no longer causes BSD definitions to be preferred in case\nof conflicts.\n\nSince glibc 2.20, this macro is deprecated.  It now has the same  effect  as  defining\nDEFAULTSOURCE,  but generates a compile-time warning (unless DEFAULTSOURCE is also\ndefined).  Use DEFAULTSOURCE instead.  To allow code that  requires  BSDSOURCE  in\nglibc  2.19 and earlier and DEFAULTSOURCE in glibc 2.20 and later to compile without\nwarnings, define both BSDSOURCE and DEFAULTSOURCE.\n\nSVIDSOURCE (deprecated since glibc 2.20)\nDefining this macro with any value causes header files to expose System V-derived def‐\ninitions.  (SVID == System V Interface Definition; see standards(7).)\n\nSince glibc 2.20, this macro is deprecated in the same fashion as BSDSOURCE.\n\nDEFAULTSOURCE (since glibc 2.19)\nThis macro can be defined to ensure that the \"default\" definitions are  provided  even\nwhen  the  defaults would otherwise be disabled, as happens when individual macros are\nexplicitly defined, or the compiler is invoked in one of its \"standard\"  modes  (e.g.,\ncc  -std=c99).   Defining  DEFAULTSOURCE without defining other individual macros or\ninvoking the compiler in one of its \"standard\" modes has no effect.\n\nThe \"default\" definitions comprise those required by POSIX.1-2008 and ISO C99, as well\nas various definitions originally derived from BSD and System V.  On  glibc  2.19  and\nearlier,  these defaults were approximately equivalent to explicitly defining the fol‐\nlowing:\n\ncc -DBSDSOURCE -DSVIDSOURCE -DPOSIXCSOURCE=200809\n\nATFILESOURCE (since glibc 2.4)\nDefining this macro with any value causes header files to  expose  declarations  of  a\nrange  of functions with the suffix \"at\"; see openat(2).  Since glibc 2.10, this macro\nis also implicitly defined if POSIXCSOURCE is defined with a value greater than  or\nequal to 200809L.\n"
                    },
                    {
                        "name": "_GNU_SOURCE",
                        "content": "Defining  this  macro  (with  any  value)  implicitly  defines ATFILESOURCE, LARGE‐\nFILE64SOURCE, ISOC99SOURCE, XOPENSOURCEEXTENDED, POSIXSOURCE,  POSIXCSOURCE\nwith  the  value 200809L (200112L before glibc 2.10; 199506L before glibc 2.5; 199309L\nbefore glibc 2.1) and XOPENSOURCE with the value 700 (600 before glibc 2.10; 500 be‐\nfore glibc 2.2).  In addition, various GNU-specific extensions are also exposed.\n\nSince glibc 2.19, defining GNUSOURCE also has the effect of implicitly defining DE‐\nFAULTSOURCE.  Before glibc 2.20, defining GNUSOURCE also had the effect of  implic‐\nitly defining BSDSOURCE and SVIDSOURCE.\n"
                    },
                    {
                        "name": "_REENTRANT",
                        "content": "Historically, on various C libraries it was necessary to define this macro in all mul‐\ntithreaded  code.   (Some  C  libraries may still require this.)  In glibc, this macro\nalso exposed definitions of certain reentrant functions.\n\nHowever, glibc has been thread-safe by default for many years; since  glibc  2.3,  the\nonly  effect of defining REENTRANT has been to enable one or two of the same declara‐\ntions that are also enabled by defining POSIXCSOURCE with a  value  of  199606L  or\ngreater.\n\nREENTRANT  is  now obsolete.  In glibc 2.25 and later, defining REENTRANT is equiva‐\nlent to defining POSIXCSOURCE with the value 199606L.  If a  higher  POSIX  confor‐\nmance  level  is  selected  by  any  other  means  (such  as  POSIXCSOURCE  itself,\nXOPENSOURCE, DEFAULTSOURCE, or GNUSOURCE), then defining REENTRANT has  no  ef‐\nfect.\n\nThis macro is automatically defined if one compiles with cc -pthread.\n"
                    },
                    {
                        "name": "_THREAD_SAFE",
                        "content": "Synonym  for  the  (deprecated) REENTRANT, provided for compatibility with some other\nimplementations.\n\nFORTIFYSOURCE (since glibc 2.3.4)\nDefining this macro causes some lightweight checks to  be  performed  to  detect  some\nbuffer overflow errors when employing various string and memory manipulation functions\n(for example, memcpy(3), memset(3), stpcpy(3), strcpy(3), strncpy(3), strcat(3), strn‐\ncat(3),  sprintf(3), snprintf(3), vsprintf(3), vsnprintf(3), gets(3), and wide charac‐\nter variants thereof).  For some functions, argument consistency is checked; for exam‐\nple, a check is made that open(2) has been supplied with  a  mode  argument  when  the\nspecified  flags  include  OCREAT.   Not  all problems are detected, just some common\ncases.\n\nIf FORTIFYSOURCE is set to 1, with  compiler  optimization  level  1  (gcc -O1)  and\nabove, checks that shouldn't change the behavior of conforming programs are performed.\nWith  FORTIFYSOURCE  set to 2, some more checking is added, but some conforming pro‐\ngrams might fail.\n\nSome of the checks can be performed at compile time (via macros logic  implemented  in\nheader  files),  and result in compiler warnings; other checks take place at run time,\nand result in a run-time error if the check fails.\n\nWith FORTIFYSOURCE set to 3, additional checking is added to intercept some function\ncalls used with an argument of variable size where the compiler can  deduce  an  upper\nbound  for its value.  For example, a program where malloc(3)'s size argument is vari‐\nable can now be fortified.\n\nUse of this macro requires compiler support, available since gcc 4.0  and  clang  2.6.\nUse  of FORTIFYSOURCE set to 3 requires gcc 12.0 or later, or clang 9.0 or later, in\nconjunction with glibc 2.33 or later.\n"
                    },
                    {
                        "name": "Default definitions, implicit definitions, and combining definitions",
                        "content": "If no feature test macros are explicitly defined, then the following feature test macros  are\ndefined  by default: BSDSOURCE (in glibc 2.19 and earlier), SVIDSOURCE (in glibc 2.19 and\nearlier), DEFAULTSOURCE (since  glibc  2.19),  POSIXSOURCE,  and  POSIXCSOURCE=200809L\n(200112L before glibc 2.10; 199506L before glibc 2.4; 199309L before glibc 2.1).\n\nIf  any of STRICTANSI, ISOC99SOURCE, ISOC11SOURCE (since glibc 2.18), POSIXSOURCE,\nPOSIXCSOURCE,  XOPENSOURCE,  XOPENSOURCEEXTENDED  (in  glibc   2.11   and   earlier),\nBSDSOURCE  (in  glibc 2.19 and earlier), or SVIDSOURCE (in glibc 2.19 and earlier) is ex‐\nplicitly defined, then BSDSOURCE, SVIDSOURCE, and DEFAULTSOURCE are not defined by  de‐\nfault.\n\nIf  POSIXSOURCE  and POSIXCSOURCE are not explicitly defined, and either STRICTANSI\nis not defined or XOPENSOURCE is defined with a value of 500 or more, then\n\n•  POSIXSOURCE is defined with the value 1; and\n\n•  POSIXCSOURCE is defined with one of the following values:\n\n•  2, if XOPENSOURCE is defined with a value less than 500;\n\n•  199506L, if XOPENSOURCE is defined with a value greater than or equal to 500 and less\nthan 600; or\n\n•  (since glibc 2.4) 200112L, if XOPENSOURCE is defined with a  value  greater  than  or\nequal to 600 and less than 700.\n\n•  (Since  glibc  2.10)  200809L, if XOPENSOURCE is defined with a value greater than or\nequal to 700.\n\n•  Older versions of  glibc  do  not  know  about  the  values  200112L  and  200809L  for\nPOSIXCSOURCE, and the setting of this macro will depend on the glibc version.\n\n•  If XOPENSOURCE is undefined, then the setting of POSIXCSOURCE depends on the glibc\nversion: 199506L, before glibc 2.4; 200112L, since glibc 2.4 to glibc 2.9; and 200809L,\nsince glibc 2.10.\n\nMultiple macros can be defined; the results are additive.\n"
                    }
                ]
            },
            "STANDARDS": {
                "content": "POSIX.1 specifies POSIXCSOURCE, POSIXSOURCE, and XOPENSOURCE.\n\nFILEOFFSETBITS is not specified by any standard, but is employed on some other implementa‐\ntions.\n\nBSDSOURCE,  SVIDSOURCE,  DEFAULTSOURCE,  ATFILESOURCE,  GNUSOURCE, FORTIFYSOURCE,\nREENTRANT, and THREADSAFE are specific to glibc.\n",
                "subsections": []
            },
            "HISTORY": {
                "content": "XOPENSOURCEEXTENDED was specified by XPG4v2 (aka SUSv1), but is not present in  SUSv2  and\nlater.\n",
                "subsections": []
            },
            "NOTES": {
                "content": "<features.h>  is  a  Linux/glibc-specific header file.  Other systems have an analogous file,\nbut typically with a different name.  This header file is  automatically  included  by  other\nheader  files  as  required:  it is not necessary to explicitly include it in order to employ\nfeature test macros.\n\nAccording to which of the above feature test macros are defined, <features.h> internally  de‐\nfines  various  other macros that are checked by other glibc header files.  These macros have\nnames prefixed by two underscores (e.g., USEMISC).  Programs  should  never  define  these\nmacros directly: instead, the appropriate feature test macro(s) from the list above should be\nemployed.\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "The  program below can be used to explore how the various feature test macros are set depend‐\ning on the glibc version and what feature test macros  are  explicitly  set.   The  following\nshell session, on a system with glibc 2.10, shows some examples of what we would see:\n\n$ cc ftm.c\n$ ./a.out\nPOSIXSOURCE defined\nPOSIXCSOURCE defined: 200809L\nBSDSOURCE defined\nSVIDSOURCE defined\nATFILESOURCE defined\n$ cc -DXOPENSOURCE=500 ftm.c\n$ ./a.out\nPOSIXSOURCE defined\nPOSIXCSOURCE defined: 199506L\nXOPENSOURCE defined: 500\n$ cc -DGNUSOURCE ftm.c\n$ ./a.out\nPOSIXSOURCE defined\nPOSIXCSOURCE defined: 200809L\nISOC99SOURCE defined\nXOPENSOURCE defined: 700\nXOPENSOURCEEXTENDED defined\nLARGEFILE64SOURCE defined\nBSDSOURCE defined\nSVIDSOURCE defined\nATFILESOURCE defined\nGNUSOURCE defined\n",
                "subsections": [
                    {
                        "name": "Program source",
                        "content": "/* ftm.c */\n\n#include <stdint.h>\n#include <stdio.h>\n#include <unistd.h>\n#include <stdlib.h>\n\nint\nmain(int argc, char *argv[])\n{\n#ifdef POSIXSOURCE\nprintf(\"POSIXSOURCE defined\\n\");\n#endif\n\n#ifdef POSIXCSOURCE\nprintf(\"POSIXCSOURCE defined: %jdL\\n\",\n(intmaxt) POSIXCSOURCE);\n#endif\n\n#ifdef ISOC99SOURCE\nprintf(\"ISOC99SOURCE defined\\n\");\n#endif\n\n#ifdef ISOC11SOURCE\nprintf(\"ISOC11SOURCE defined\\n\");\n#endif\n\n#ifdef XOPENSOURCE\nprintf(\"XOPENSOURCE defined: %d\\n\", XOPENSOURCE);\n#endif\n\n#ifdef XOPENSOURCEEXTENDED\nprintf(\"XOPENSOURCEEXTENDED defined\\n\");\n#endif\n\n#ifdef LARGEFILE64SOURCE\nprintf(\"LARGEFILE64SOURCE defined\\n\");\n#endif\n\n#ifdef FILEOFFSETBITS\nprintf(\"FILEOFFSETBITS defined: %d\\n\", FILEOFFSETBITS);\n#endif\n\n#ifdef TIMEBITS\nprintf(\"TIMEBITS defined: %d\\n\", TIMEBITS);\n#endif\n\n#ifdef BSDSOURCE\nprintf(\"BSDSOURCE defined\\n\");\n#endif\n\n#ifdef SVIDSOURCE\nprintf(\"SVIDSOURCE defined\\n\");\n#endif\n\n#ifdef DEFAULTSOURCE\nprintf(\"DEFAULTSOURCE defined\\n\");\n#endif\n\n#ifdef ATFILESOURCE\nprintf(\"ATFILESOURCE defined\\n\");\n#endif\n\n#ifdef GNUSOURCE\nprintf(\"GNUSOURCE defined\\n\");\n#endif\n\n#ifdef REENTRANT\nprintf(\"REENTRANT defined\\n\");\n#endif\n\n#ifdef THREADSAFE\nprintf(\"THREADSAFE defined\\n\");\n#endif\n\n#ifdef FORTIFYSOURCE\nprintf(\"FORTIFYSOURCE defined\\n\");\n#endif\n\nexit(EXITSUCCESS);\n}\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "libc(7), standards(7), systemdatatypes(7)\n\nThe section \"Feature Test Macros\" under info libc.\n\n/usr/include/features.h\n\nLinux man-pages 6.7                          2023-10-31                       featuretestmacros(7)",
                "subsections": []
            }
        }
    }
}