# feature_test_macros(7) - man - phpMan

[FEATURE_TEST_MACROS(7)](https://www.chedong.com/phpMan.php/man/FEATURETESTMACROS/7/markdown)                Linux Programmer's Manual               [FEATURE_TEST_MACROS(7)](https://www.chedong.com/phpMan.php/man/FEATURETESTMACROS/7/markdown)



## NAME
       feature_test_macros - feature test macros

## DESCRIPTION
       Feature  test macros allow the programmer to control the definitions that are exposed by sys‐
       tem header files when a program is compiled.

       **NOTE:** In order to be effective, a feature test macro _must_ _be_  _defined_  _before_  _including_  _any_
       _header_  _files_.   This  can be done either in the compilation command (_cc_ _-DMACRO=value_) or by
       defining the macro within the source code before including any headers.  The requirement that
       the  macro  must  be defined before including any header file exists because header files may
       freely include one another.   Thus,  for  example,  in  the  following  lines,  defining  the
       ___**GNU**___**SOURCE**  macro  may  have  no  effect  because the header _<abc.h>_ itself includes _<xyz.h>_
       (POSIX explicitly allows this):

           #include <abc.h>
           #define _GNU_SOURCE
           #include <xyz.h>

       Some feature test macros are useful for creating portable applications,  by  preventing  non‐
       standard definitions from being exposed.  Other macros can be used to expose nonstandard def‐
       initions that are not exposed by default.

       The precise effects of each of the feature test macros described below can be ascertained  by
       inspecting  the _<features.h>_ header file.  **Note**: applications do _not_ need to directly include
       _<features.h>_; indeed, doing so is actively discouraged.  See NOTES.

### Specification of feature test macro requirements in manual pages
       When a function requires that a feature test macro is defined, the manual page SYNOPSIS typi‐
       cally includes a note of the following form (this example from the [**acct**(2)](https://www.chedong.com/phpMan.php/man/acct/2/markdown) manual page):

              **#include** **<unistd.h>**

              **int** **acct(const** **char** *****_filename_**);**

          Feature Test Macro Requirements for glibc (see
          **feature**___**test**___**[macros**(7)](https://www.chedong.com/phpMan.php/man/macros/7/markdown)):

              **acct**(): _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)

       The  **||**  means  that in order to obtain the declaration of [**acct**(2)](https://www.chedong.com/phpMan.php/man/acct/2/markdown) from _<unistd.h>_, _either_ of
       the following macro definitions must be made before including any header files:

           #define _BSD_SOURCE
           #define _XOPEN_SOURCE        /* or any value < 500 */

       Alternatively, equivalent definitions can be included in the compilation command:

           cc -D_BSD_SOURCE
           cc -D_XOPEN_SOURCE           # Or any value < 500

       Note that, as described below, **some** **feature** **test** **macros** **are** **defined** **by** **default**,  so  that  it
       may not always be necessary to explicitly specify the feature test macro(s) shown in the SYN‐
       OPSIS.

       In a few cases, manual pages use a shorthand for expressing the feature test  macro  require‐
       ments (this example from [**readahead**(2)](https://www.chedong.com/phpMan.php/man/readahead/2/markdown)):

           **#define** ___**GNU**___**SOURCE**
           **#include** **<fcntl.h>**

           **ssize**___**t** **readahead(int** _fd_**,** **off64**___**t** *****_offset_**,** **size**___**t** _count_**);**

       This format is employed in cases where only a single feature test macro can be used to expose
       the function declaration, and that macro is not defined by default.

### Feature test macros understood by glibc
       The paragraphs below explain how feature test macros are handled in Linux glibc 2._x_, _x_ > 0.

       First, though a summary of a few details for the impatient:

       *  The macros that you most likely need to use in modern source code are ___**POSIX**___**C**___**SOURCE** (for
          definitions from various versions of POSIX.1), ___**XOPEN**___**SOURCE** (for definitions from various
          versions of SUS), ___**GNU**___**SOURCE** (for GNU and/or Linux specific stuff),  and  ___**DEFAULT**___**SOURCE**
          (to get definitions that would normally be provided by default).

       *  Certain  macros are defined with default values.  Thus, although one or more macros may be
          indicated as being required in the SYNOPSIS of a man page, it may not be necessary to  de‐
          fine them explicitly.  Full details of the defaults are given later in this man page.

       *  Defining  ___**XOPEN**___**SOURCE** with a value of 600 or greater produces the same effects as defin‐
          ing ___**POSIX**___**C**___**SOURCE** with a value of 200112L or greater.  Where one sees

              _POSIX_C_SOURCE >= 200112L

          in the feature test macro requirements in the SYNOPSIS of a man page, it is implicit  that
          the following has the same effect:

              _XOPEN_SOURCE >= 600

       *  Defining  ___**XOPEN**___**SOURCE** with a value of 700 or greater produces the same effects as defin‐
          ing ___**POSIX**___**C**___**SOURCE** with a value of 200809L or greater.  Where one sees

              _POSIX_C_SOURCE >= 200809L

          in the feature test macro requirements in the SYNOPSIS of a man page, it is implicit  that
          the following has the same effect:

              _XOPEN_SOURCE >= 700

       Linux glibc understands the following feature test macros:

       ____**STRICT**___**ANSI**____
              ISO Standard C.  This macro is implicitly defined by [**gcc**(1)](https://www.chedong.com/phpMan.php/man/gcc/1/markdown) when invoked with, for ex‐
              ample, the _-std=c99_ or _-ansi_ flag.

       ___**POSIX**___**C**___**SOURCE**
              Defining this macro causes header files to expose definitions as follows:

              •  The value 1 exposes definitions conforming to POSIX.1-1990 and ISO C (1990).

              •  The value 2 or greater additionally exposes definitions for POSIX.2-1992.

              •  The value 199309L or greater additionally exposes definitions for  POSIX.1b  (real-
                 time extensions).

              •  The  value  199506L  or  greater  additionally  exposes  definitions  for  POSIX.1c
                 (threads).

              •  (Since glibc 2.3.3) The value 200112L or greater additionally  exposes  definitions
                 corresponding to the POSIX.1-2001 base specification (excluding the XSI extension).
                 This value also causes C95 (since glibc 2.12) and C99 (since glibc  2.10)  features
                 to be exposed (in other words, the equivalent of defining ___**ISOC99**___**SOURCE**).

              •  (Since  glibc  2.10)  The value 200809L or greater additionally exposes definitions
                 corresponding to the POSIX.1-2008 base specification (excluding the XSI extension).

       ___**POSIX**___**SOURCE**
              Defining this obsolete macro with any value is equivalent to defining  ___**POSIX**___**C**___**SOURCE**
              with the value 1.

              Since  this  macro  is obsolete, its usage is generally not documented when discussing
              feature test macro requirements in the man pages.

       ___**XOPEN**___**SOURCE**
              Defining this macro causes header files to expose definitions as follows:

              •  Defining with any value exposes definitions conforming  to  POSIX.1,  POSIX.2,  and
                 XPG4.

              •  The value 500 or greater additionally exposes definitions for SUSv2 (UNIX 98).

              •  (Since  glibc  2.2)  The  value 600 or greater additionally exposes definitions for
                 SUSv3 (UNIX 03; i.e., the POSIX.1-2001 base specification plus the  XSI  extension)
                 and C99 definitions.

              •  (Since  glibc  2.10)  The value 700 or greater additionally exposes definitions for
                 SUSv4 (i.e., the POSIX.1-2008 base specification plus the XSI extension).

              If ____**STRICT**___**ANSI**____ is not defined, or ___**XOPEN**___**SOURCE** is defined with  a  value  greater
              than  or  equal to 500 _and_ neither ___**POSIX**___**SOURCE** nor ___**POSIX**___**C**___**SOURCE** is explicitly de‐
              fined, then the following macros are implicitly defined:

              •  ___**POSIX**___**SOURCE** is defined with the value 1.

              •  ___**POSIX**___**C**___**SOURCE** is defined, according to the value of ___**XOPEN**___**SOURCE**:

                 ___**XOPEN**___**SOURCE** < 500
                        ___**POSIX**___**C**___**SOURCE** is defined with the value 2.

                 500 <= ___**XOPEN**___**SOURCE** < 600
                        ___**POSIX**___**C**___**SOURCE** is defined with the value 199506L.

                 600 <= ___**XOPEN**___**SOURCE** < 700
                        ___**POSIX**___**C**___**SOURCE** is defined with the value 200112L.

                 700 <= ___**XOPEN**___**SOURCE** (since glibc 2.10)
                        ___**POSIX**___**C**___**SOURCE** is defined with the value 200809L.

              In addition, defining ___**XOPEN**___**SOURCE** with a value of 500 or greater produces  the  same
              effects as defining ___**XOPEN**___**SOURCE**___**EXTENDED**.

       ___**XOPEN**___**SOURCE**___**EXTENDED**
              If this macro is defined, _and_ ___**XOPEN**___**SOURCE** is defined, then expose definitions corre‐
              sponding to the XPG4v2 (SUSv1) UNIX extensions (UNIX 95).  Defining ___**XOPEN**___**SOURCE** with
              a  value  of  500  or more also produces the same effect as defining ___**XOPEN**___**SOURCE**___**EX**‐‐
              **TENDED**.  Use of ___**XOPEN**___**SOURCE**___**EXTENDED** in new source code should be avoided.

              Since defining ___**XOPEN**___**SOURCE** with a value of 500 or more has the same effect as defin‐
              ing  ___**XOPEN**___**SOURCE**___**EXTENDED**, the latter (obsolete) feature test macro is generally not
              described in the SYNOPSIS in man pages.

       ___**ISOC99**___**SOURCE** (since glibc 2.1.3)
              Exposes declarations consistent with the ISO C99 standard.

              Earlier glibc 2.1.x versions recognized an equivalent macro named ___**ISOC9X**___**SOURCE**  (be‐
              cause  the  C99 standard had not then been finalized).  Although the use of this macro
              is obsolete, glibc continues to recognize it for backward compatibility.

              Defining ___**ISOC99**___**SOURCE** also exposes ISO C (1990)  Amendment  1  ("C95")  definitions.
              (The primary change in C95 was support for international character sets.)

              Invoking the C compiler with the option _-std=c99_ produces the same effects as defining
              this macro.

       ___**ISOC11**___**SOURCE** (since glibc 2.16)
              Exposes declarations consistent with the ISO C11 standard.  Defining this  macro  also
              enables C99 and C95 features (like ___**ISOC99**___**SOURCE**).

              Invoking the C compiler with the option _-std=c11_ produces the same effects as defining
              this macro.

       ___**LARGEFILE64**___**SOURCE**
              Expose definitions for the alternative API specified by the LFS (Large File Summit) as
              a   "transitional   extension"   to  the  Single  UNIX  Specification.   (See  ⟨http:/
              /opengroup.org/platform/lfs.html⟩.)  The alternative API consists of a set of new  ob‐
              jects  (i.e.,  functions  and types) whose names are suffixed with "64" (e.g., _off64_t_
              versus _off_t_, **lseek64**() versus **lseek**(), etc.).  New programs should  not  employ  this
              macro; instead __FILE_OFFSET_BITS=64_ should be employed.

       ___**LARGEFILE**___**SOURCE**
              This  macro  was historically used to expose certain functions (specifically [**fseeko**(3)](https://www.chedong.com/phpMan.php/man/fseeko/3/markdown)
              and [**ftello**(3)](https://www.chedong.com/phpMan.php/man/ftello/3/markdown)) that address limitations of earlier APIs ([**fseek**(3)](https://www.chedong.com/phpMan.php/man/fseek/3/markdown) and  [**ftell**(3)](https://www.chedong.com/phpMan.php/man/ftell/3/markdown))  that
              use  _long_  for file offsets.  This macro is implicitly defined if ___**XOPEN**___**SOURCE** is de‐
              fined with a value greater than or equal to 500.  New programs should not employ  this
              macro; defining ___**XOPEN**___**SOURCE** as just described or defining ___**FILE**___**OFFSET**___**BITS** with the
              value 64 is the preferred mechanism to achieve the same result.

       ___**FILE**___**OFFSET**___**BITS**
              Defining this macro with the value 64  automatically  converts  references  to  32-bit
              functions and data types related to file I/O and filesystem operations into references
              to their 64-bit counterparts.  This is useful for performing I/O on large files  (>  2
              Gigabytes) on 32-bit systems.  (Defining this macro permits correctly written programs
              to use large files with only a recompilation being required.)

              64-bit systems naturally permit file sizes greater than 2 Gigabytes, and on those sys‐
              tems this macro has no effect.

       ___**BSD**___**SOURCE** (deprecated since glibc 2.20)
              Defining  this  macro with any value causes header files to expose BSD-derived defini‐
              tions.

              In glibc versions up to and including 2.18, defining this macro also causes BSD  defi‐
              nitions  to  be  preferred  in some situations where standards conflict, unless one or
              more of ___**SVID**___**SOURCE**, ___**POSIX**___**SOURCE**, ___**POSIX**___**C**___**SOURCE**, ___**XOPEN**___**SOURCE**, ___**XOPEN**___**SOURCE**___**EX**‐‐
              **TENDED**,  or  ___**GNU**___**SOURCE**  is  defined,  in  which case BSD definitions are disfavored.
              Since glibc 2.19, ___**BSD**___**SOURCE** no longer causes BSD definitions to be preferred in case
              of conflicts.

              Since  glibc  2.20,  this macro is deprecated.  It now has the same effect as defining
              ___**DEFAULT**___**SOURCE**, but generates a compile-time warning (unless ___**DEFAULT**___**SOURCE** is  also
              defined).   Use  ___**DEFAULT**___**SOURCE**  instead.  To allow code that requires ___**BSD**___**SOURCE** in
              glibc 2.19 and earlier and ___**DEFAULT**___**SOURCE** in glibc 2.20 and later to compile  without
              warnings, define _both_ ___**BSD**___**SOURCE** and ___**DEFAULT**___**SOURCE**.

       ___**SVID**___**SOURCE** (deprecated since glibc 2.20)
              Defining this macro with any value causes header files to expose System V-derived def‐
              initions.  (SVID == System V Interface Definition; see [**standards**(7)](https://www.chedong.com/phpMan.php/man/standards/7/markdown).)

              Since glibc 2.20, this macro is deprecated in the same fashion as ___**BSD**___**SOURCE**.

       ___**DEFAULT**___**SOURCE** (since glibc 2.19)
              This macro can be defined to ensure that the "default" definitions are  provided  even
              when  the  defaults would otherwise be disabled, as happens when individual macros are
              explicitly defined, or the compiler is invoked in one of its "standard"  modes  (e.g.,
              _cc_ _-std=c99_).   Defining  ___**DEFAULT**___**SOURCE**  without defining other individual macros or
              invoking the compiler in one of its "standard" modes has no effect.

              The "default" definitions comprise those required by POSIX.1-2008 and ISO C99, as well
              as  various  definitions  originally derived from BSD and System V.  On glibc 2.19 and
              earlier, these defaults were approximately equivalent to explicitly defining the  fol‐
              lowing:

                  cc -D_BSD_SOURCE -D_SVID_SOURCE -D_POSIX_C_SOURCE=200809

       ___**ATFILE**___**SOURCE** (since glibc 2.4)
              Defining  this  macro  with  any value causes header files to expose declarations of a
              range of functions with the suffix "at"; see [**openat**(2)](https://www.chedong.com/phpMan.php/man/openat/2/markdown).  Since glibc 2.10, this  macro
              is  also implicitly defined if ___**POSIX**___**C**___**SOURCE** is defined with a value greater than or
              equal to 200809L.

       ___**GNU**___**SOURCE**
              Defining this macro  (with  any  value)  implicitly  defines  ___**ATFILE**___**SOURCE**,  ___**LARGE**‐‐
              **FILE64**___**SOURCE**,  ___**ISOC99**___**SOURCE**, ___**XOPEN**___**SOURCE**___**EXTENDED**, ___**POSIX**___**SOURCE**, ___**POSIX**___**C**___**SOURCE**
              with the value 200809L (200112L in glibc versions before 2.10; 199506L in  glibc  ver‐
              sions  before  2.5;  199309L  in glibc versions before 2.1) and ___**XOPEN**___**SOURCE** with the
              value 700 (600 in glibc versions before 2.10; 500 in glibc versions before  2.2).   In
              addition, various GNU-specific extensions are also exposed.

              Since glibc 2.19, defining ___**GNU**___**SOURCE** also has the effect of implicitly defining ___**DE**‐‐
              **FAULT**___**SOURCE**.  In glibc versions before 2.20, defining ___**GNU**___**SOURCE** also had the effect
              of implicitly defining ___**BSD**___**SOURCE** and ___**SVID**___**SOURCE**.

       ___**REENTRANT**
              Historically, on various C libraries it was necessary to define this macro in all mul‐
              tithreaded code.  (Some C libraries may still require this.)   In  glibc,  this  macro
              also exposed definitions of certain reentrant functions.

              However,  glibc  has  been thread-safe by default for many years; since glibc 2.3, the
              only effect of defining ___**REENTRANT** has been to enable one or two of the same  declara‐
              tions  that  are  also  enabled by defining ___**POSIX**___**C**___**SOURCE** with a value of 199606L or
              greater.

              ___**REENTRANT** is now obsolete.  In glibc 2.25 and later, defining ___**REENTRANT**  is  equiva‐
              lent  to  defining  ___**POSIX**___**C**___**SOURCE** with the value 199606L.  If a higher POSIX confor‐
              mance  level  is  selected  by  any  other  means  (such  as  ___**POSIX**___**C**___**SOURCE**  itself,
              ___**XOPEN**___**SOURCE**,  ___**DEFAULT**___**SOURCE**,  or ___**GNU**___**SOURCE**), then defining ___**REENTRANT** has no ef‐
              fect.

              This macro is automatically defined if one compiles with _cc_ _-pthread_.

       ___**THREAD**___**SAFE**
              Synonym for the (deprecated) ___**REENTRANT**, provided for compatibility  with  some  other
              implementations.

       ___**FORTIFY**___**SOURCE** (since glibc 2.3.4)
              Defining this macro causes some lightweight checks to be performed to detect some buf‐
              fer overflow errors when employing various string and  memory  manipulation  functions
              (for example, [**memcpy**(3)](https://www.chedong.com/phpMan.php/man/memcpy/3/markdown), [**memset**(3)](https://www.chedong.com/phpMan.php/man/memset/3/markdown), [**stpcpy**(3)](https://www.chedong.com/phpMan.php/man/stpcpy/3/markdown), [**strcpy**(3)](https://www.chedong.com/phpMan.php/man/strcpy/3/markdown), [**strncpy**(3)](https://www.chedong.com/phpMan.php/man/strncpy/3/markdown), [**strcat**(3)](https://www.chedong.com/phpMan.php/man/strcat/3/markdown), **strn**‐‐
              [**cat**(3)](https://www.chedong.com/phpMan.php/man/cat/3/markdown), [**sprintf**(3)](https://www.chedong.com/phpMan.php/man/sprintf/3/markdown), [**snprintf**(3)](https://www.chedong.com/phpMan.php/man/snprintf/3/markdown), [**vsprintf**(3)](https://www.chedong.com/phpMan.php/man/vsprintf/3/markdown), [**vsnprintf**(3)](https://www.chedong.com/phpMan.php/man/vsnprintf/3/markdown), [**gets**(3)](https://www.chedong.com/phpMan.php/man/gets/3/markdown), and wide  charac‐
              ter variants thereof).  For some functions, argument consistency is checked; for exam‐
              ple, a check is made that [**open**(2)](https://www.chedong.com/phpMan.php/man/open/2/markdown) has been supplied with  a  _mode_  argument  when  the
              specified  flags  include  **O**___**CREAT**.   Not  all problems are detected, just some common
              cases.

              If ___**FORTIFY**___**SOURCE** is set to 1, with  compiler  optimization  level  1  (_gcc_ _-O1_)  and
              above, checks that shouldn't change the behavior of conforming programs are performed.
              With ___**FORTIFY**___**SOURCE** set to 2, some more checking is added, but some  conforming  pro‐
              grams might fail.

              Some  of  the checks can be performed at compile time (via macros logic implemented in
              header files), and result in compiler warnings; other checks take place at  run  time,
              and result in a run-time error if the check fails.

              Use of this macro requires compiler support, available with [**gcc**(1)](https://www.chedong.com/phpMan.php/man/gcc/1/markdown) since version 4.0.

### Default definitions, implicit definitions, and combining definitions
       If  no feature test macros are explicitly defined, then the following feature test macros are
       defined by default: ___**BSD**___**SOURCE** (in glibc 2.19 and earlier), ___**SVID**___**SOURCE** (in glibc 2.19  and
       earlier),  ___**DEFAULT**___**SOURCE**  (since  glibc  2.19),  ___**POSIX**___**SOURCE**, and ___**POSIX**___**C**___**SOURCE**=200809L
       (200112L in glibc versions before 2.10; 199506L in glibc  versions  before  2.4;  199309L  in
       glibc versions before 2.1).

       If  any of ____**STRICT**___**ANSI**____, ___**ISOC99**___**SOURCE**, ___**ISOC11**___**SOURCE** (since glibc 2.18), ___**POSIX**___**SOURCE**,
       ___**POSIX**___**C**___**SOURCE**,  ___**XOPEN**___**SOURCE**,  ___**XOPEN**___**SOURCE**___**EXTENDED**  (in  glibc   2.11   and   earlier),
       ___**BSD**___**SOURCE**  (in  glibc 2.19 and earlier), or ___**SVID**___**SOURCE** (in glibc 2.19 and earlier) is ex‐
       plicitly defined, then ___**BSD**___**SOURCE**, ___**SVID**___**SOURCE**, and ___**DEFAULT**___**SOURCE** are not defined by  de‐
       fault.

       If  ___**POSIX**___**SOURCE**  and ___**POSIX**___**C**___**SOURCE** are not explicitly defined, and either ____**STRICT**___**ANSI**____
       is not defined or ___**XOPEN**___**SOURCE** is defined with a value of 500 or more, then

       *  ___**POSIX**___**SOURCE** is defined with the value 1; and

       *  ___**POSIX**___**C**___**SOURCE** is defined with one of the following values:

          •  2, if ___**XOPEN**___**SOURCE** is defined with a value less than 500;

          •  199506L, if ___**XOPEN**___**SOURCE** is defined with a value greater than or equal to 500 and less
             than 600; or

          •  (since  glibc  2.4)  200112L,  if ___**XOPEN**___**SOURCE** is defined with a value greater than or
             equal to 600 and less than 700.

          •  (Since glibc 2.10) 200809L, if ___**XOPEN**___**SOURCE** is defined with a value  greater  than  or
             equal to 700.

          •  Older  versions  of  glibc  do  not  know  about  the  values  200112L  and 200809L for
             ___**POSIX**___**C**___**SOURCE**, and the setting of this macro will depend on the glibc version.

          •  If ___**XOPEN**___**SOURCE** is undefined, then the setting of ___**POSIX**___**C**___**SOURCE** depends on the glibc
             version:  199506L,  in  glibc  versions  before  2.4; 200112L, in glibc 2.4 to 2.9; and
             200809L, since glibc 2.10.

       Multiple macros can be defined; the results are additive.

## CONFORMING TO
       POSIX.1 specifies ___**POSIX**___**C**___**SOURCE**, ___**POSIX**___**SOURCE**, and ___**XOPEN**___**SOURCE**.

       ___**XOPEN**___**SOURCE**___**EXTENDED** was specified by XPG4v2 (aka SUSv1), but is not present in  SUSv2  and
       later.  ___**FILE**___**OFFSET**___**BITS** is not specified by any standard, but is employed on some other im‐
       plementations.

       ___**BSD**___**SOURCE**, ___**SVID**___**SOURCE**,  ___**DEFAULT**___**SOURCE**,  ___**ATFILE**___**SOURCE**,  ___**GNU**___**SOURCE**,  ___**FORTIFY**___**SOURCE**,
       ___**REENTRANT**, and ___**THREAD**___**SAFE** are specific to Linux (glibc).

## NOTES
       _<features.h>_  is  a  Linux/glibc-specific header file.  Other systems have an analogous file,
       but typically with a different name.  This header file is  automatically  included  by  other
       header  files  as  required:  it is not necessary to explicitly include it in order to employ
       feature test macros.

       According to which of the above feature test macros are defined, _<features.h>_ internally  de‐
       fines  various  other macros that are checked by other glibc header files.  These macros have
       names prefixed by two underscores (e.g., ____**USE**___**MISC**).  Programs  should  _never_  define  these
       macros directly: instead, the appropriate feature test macro(s) from the list above should be
       employed.

## 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**
           _POSIX_SOURCE defined
           _POSIX_C_SOURCE defined: 200809L
           _BSD_SOURCE defined
           _SVID_SOURCE defined
           _ATFILE_SOURCE defined
           $ **cc** **-D**___**XOPEN**___**SOURCE=500** **ftm.c**
           $ **./a.out**
           _POSIX_SOURCE defined
           _POSIX_C_SOURCE defined: 199506L
           _XOPEN_SOURCE defined: 500
           $ **cc** **-D**___**GNU**___**SOURCE** **ftm.c**
           $ **./a.out**
           _POSIX_SOURCE defined
           _POSIX_C_SOURCE defined: 200809L
           _ISOC99_SOURCE defined
           _XOPEN_SOURCE defined: 700
           _XOPEN_SOURCE_EXTENDED defined
           _LARGEFILE64_SOURCE defined
           _BSD_SOURCE defined
           _SVID_SOURCE defined
           _ATFILE_SOURCE defined
           _GNU_SOURCE defined

### Program source

       /* ftm.c */

       #include <stdint.h>
       #include <stdio.h>
       #include <unistd.h>
       #include <stdlib.h>

       int
       main(int argc, char *argv[])
       {
       #ifdef _POSIX_SOURCE
           printf("_POSIX_SOURCE defined\n");
       #endif

       #ifdef _POSIX_C_SOURCE
           printf("_POSIX_C_SOURCE defined: %jdL\n",
                   (intmax_t) _POSIX_C_SOURCE);
       #endif

       #ifdef _ISOC99_SOURCE
           printf("_ISOC99_SOURCE defined\n");
       #endif

       #ifdef _ISOC11_SOURCE
           printf("_ISOC11_SOURCE defined\n");
       #endif

       #ifdef _XOPEN_SOURCE
           printf("_XOPEN_SOURCE defined: %d\n", _XOPEN_SOURCE);
       #endif

       #ifdef _XOPEN_SOURCE_EXTENDED
           printf("_XOPEN_SOURCE_EXTENDED defined\n");
       #endif

       #ifdef _LARGEFILE64_SOURCE
           printf("_LARGEFILE64_SOURCE defined\n");
       #endif

       #ifdef _FILE_OFFSET_BITS
           printf("_FILE_OFFSET_BITS defined: %d\n", _FILE_OFFSET_BITS);
       #endif

       #ifdef _BSD_SOURCE
           printf("_BSD_SOURCE defined\n");
       #endif

       #ifdef _SVID_SOURCE
           printf("_SVID_SOURCE defined\n");
       #endif

       #ifdef _DEFAULT_SOURCE
           printf("_DEFAULT_SOURCE defined\n");
       #endif

       #ifdef _ATFILE_SOURCE
           printf("_ATFILE_SOURCE defined\n");
       #endif

       #ifdef _GNU_SOURCE
           printf("_GNU_SOURCE defined\n");
       #endif

       #ifdef _REENTRANT
           printf("_REENTRANT defined\n");
       #endif

       #ifdef _THREAD_SAFE
           printf("_THREAD_SAFE defined\n");
       #endif

       #ifdef _FORTIFY_SOURCE
           printf("_FORTIFY_SOURCE defined\n");
       #endif

           exit(EXIT_SUCCESS);
       }

## SEE ALSO
       [**libc**(7)](https://www.chedong.com/phpMan.php/man/libc/7/markdown), [**standards**(7)](https://www.chedong.com/phpMan.php/man/standards/7/markdown), **system**___**data**___**[types**(7)](https://www.chedong.com/phpMan.php/man/types/7/markdown)

       The section "Feature Test Macros" under _info_ _libc_.

       _/usr/include/features.h_

## COLOPHON
       This page is part of release 5.10 of the Linux  _man-pages_  project.   A  description  of  the
       project,  information about reporting bugs, and the latest version of this page, can be found
       at <https://www.kernel.org/doc/man-pages/>.



Linux                                        2020-11-01                       [FEATURE_TEST_MACROS(7)](https://www.chedong.com/phpMan.php/man/FEATURETESTMACROS/7/markdown)
