feature_test_macrosのヘルプ・マニュアル
日本語 英語
feature_test_macros --help
man feature_test_macros
FEATURE_TEST_MACROS(7) Linux Programmer’s Manual FEATURE_TEST_MACROS(7)
名前
feature_test_macros - 機能検査マクロ
書式
#include
説明
機 能検査マクロ (feature test macro) により、プログラマはプログラムがコ
ンパイルされる際にシステムのヘッダファイルにより公開される定義を制御 す
る ことができる。この機能を使うと、非標準の定義が公開されないようにでき
、移植性のあるアプリケーションを作成するのに役立つ。他のマクロを使う と
、 デフォルトでは公開されない非標準の定義を公開することができる。以下で
説明する機能検査マクロのそれぞれの正確な影響を確認するには、ヘッダフ ァ
イル を調べればよい。
機 能検査マクロを機能させるには、機能検査マクロの定義を「どのヘッダファ
イルのインクルードよりも前で」行わなければならない。これを実現するに は
、 コンパイルコマンドで指定する方法 (cc -DMACRO=value) と、ソースコード
内で必要なマクロの定義をどのヘッダのインクルードよりも前で行う方法が あ
る。
マニュアルページでの機能検査マクロの要件の規定
関 数 が 機 能 検査マクロの定義を必要とする場合、マニュアルページの書式
(SYNOPSIS) の節に以下の形式の注釈を入れる (以下の例は chmod(2) のマニュ
アルページからの引用である)。
#include
int chmod(const char *path, mode_t mode);
int fchmod(int fd, mode_t mode);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
fchmod(): _BSD_SOURCE || _XOPEN_SOURCE >= 500
|| は、 fchmod(2) の定義を から得るには、以下のマクロの定
義のいずれかを、どのヘッダファイルのインクルードよりも前で行わなけれ ば
ならないことを意味する。
#define _BSD_SOURCE
#define _XOPEN_SOURCE 500 /* or any value > 500 */
別 の方法としては、等価な定義をコンパイル用のコマンドで指定することもで
きる。
cc -D_BSD_SOURCE
cc -D_XOPEN_SOURCE=500 # Or any value > 500
後で述べるが、 「いくつかの機能検査マクロはデフォルトで定義される」点に
注 意すること。このため、「書式」に記載された機能検査マクロを常に明示的
に指定する必要があるわけではない。
あまり多くないが、マニュアルページによっては、機能検査マクロの要件を 以
下 のように簡単な表現で記載する場合がある。 (以下の例は readahead(2) の
マニュアルページからの引用である)。
#define _GNU_SOURCE
#include
ssize_t readahead(int fd, off64_t *offset, size_t count);
関数定義の公開に使える機能検査マクロが一つだけで、デフォルトではその マ
クロが定義されない場合に、この形式の表現を利用する。
glibc が解釈する機能検査マクロ
以 下では、Linux glibc 2.x (x > 0) において、機能検査マクロがどのように
扱われるかを説明する。
Linux/glibc は以下の機能検査マクロを解釈する:
__STRICT_ANSI__
ISO 標準の C。 gcc(1) を -std=c99 や -ansi などのフラグを付け て
起動した場合、このマクロは暗黙のうちに定義される。
_POSIX_C_SOURCE
このマクロを定義すると、ヘッダファイルで以下の定義が公開される。
· 値が 1 の場合、POSIX.1-1990 と ISO C (1990) に準拠する定義 が
公開される。
· 値が 2 以上の場合、 POSIX.2-1992 関連の定義も追加で公開される
。
· 値が 199309 以上の場合、 POSIX.1b (リアルタイム拡張) 関連の定
義が追加で公開される。
· 値が 199506 以上の場合、 POSIX.1c (スレッド) 関連の定義が追加
で公開される。
· (glibc 2.3.3 以降) 値が 200112 の場合、 (XSI 拡 張 を 除 く)
POSIX.1-2001 基本仕様に対応する定義が公開される。
_POSIX_SOURCE
このマクロは廃止予定である。このマクロが定義されると、値に関わら
ず、 _POSIX_C_SOURCE を値 1 で定義するのと等価となる。
_XOPEN_SOURCE
このマクロを定義すると、ヘッダファイルで以下の定義が公開される。
· どんな値でも、ヘッダファイルで POSIX.1, POSIX.2, XPG4 に準拠
する定義が公開される。
· 値が 500 以上の場合、 SUSv2 (UNIX 98) 関連の定義が追加で公 開
される。
· (glibc 2.2 以 降) 値 が 600 以上の場合、 SUSv3 (UNIX 03;
POSIX.1-2001 基本仕様 + XSI 拡張と同じ) 関連の定義と C99 での
定義が追加で公開される。
_XOPEN_SOURCE_EXTENDED
こ の マ クロが定義され、さらに _XOPEN_SOURCE が定義されていると
、XPG4v2 (SUSv1) UNIX 拡張 (UNIX 95) に対応する定義が公開され る
。 _XOPEN_SOURCE が 500 以上の値で定義された場合、このマクロは暗
黙のうちに定義される。
_ISOC99_SOURCE
ISO C (1990) の C99 拡張を公開する。このマクロは glibc 2.1.3 以
降で認識される。初期のバージョン 2.1.x の glibc では、これと等価
な _ISOC9X_SOURCE という名前のマクロが使われていた ( な ぜ な ら
、C99 標準はまだ確定していなかったからである)。 _ISOC9X_SOURCE
マクロの使用は廃止されているが、 glibc は過去との互換性のため 今
でもこのマクロを認識する。
_LARGEFILE64_SOURCE
LFS (Large File Summit) により "暫定拡張 (transitional exten-
sion)" Single UNIX Specification として規 定 さ れ た 代 替 API
(alternative API) に 関 す る 定 義 を 公開する (http://open-
group.org/platform/lfs.html 参照)。代替 API は新規オブジェクト (
関 数 と型) の集合で構成され、その名前は "64" で終わる (例えば、
off_t に対応するのは off64_t、 lseek() に対応するのは lseek64()
で ある)。新しいプログラムではこのインタフェースを利用しないこと
。代わりに _FILE_OFFSET_BITS=64 を利用すること。
_FILE_OFFSET_BITS
このマクロを値 64 で定義すると、ファイル I/O とファイルシステ ム
操作に関連する 32 ビット版の関数とデータタイプは自動的に 64 ビッ
ト版に変換される。これは、32 ビットシステムで大きなファイル (> 2
ギ ガバイト) の I/O を実行する際に役立つ (このマクロを定義すると
、コンパイルし直すだけで大きなファイルを扱えるプログラムを書くこ
とができる)。 64 ビットシステムは、もともと 2 ギガバイトより大き
なファイルを扱えるので、64 ビットシステムではこのマクロは効果 を
持たない。
_BSD_SOURCE
こ のマクロを定義すると (値に関わらず) ヘッダファイルで BSD 由来
の定義が公開される。また、このマクロを定義すると、相容れない標準
が 存在する状況において BSD 由来の定義を優先するようになる。ただ
し 、 _SVID_SOURCE, _POSIX_SOURCE, _POSIX_C_SOURCE,
_XOPEN_SOURCE, _XOPEN_SOURCE_EXTENDED, _GNU_SOURCE が一つでも定
義された場合には、BSD 由来の定義は優先されなくなる。
_SVID_SOURCE
このマクロを定義すると (値に関わらず) ヘッダファイルで System V
由 来 の定義が公開される (SVID == System V Interface Definition;
standards(7) 参照)。
_ATFILE_SOURCE (glibc 2.4 以降)
このマクロを定義すると (値に関わらず) ヘッダファイルで名前の末尾
が "at" の各種の関数の定義が公開される。 openat(2) 参照。
_GNU_SOURCE
このマクロを定義すると (値に関わらず) 以下のマクロを定義するのと
等価になる: _BSD_SOURCE, _SVID_SOURCE, _ATFILE_SOURCE, _LARGE-
FILE64_SOURCE, _ISOC99_SOURCE, _XOPEN_SOURCE_EXTENDED,
_POSIX_SOURCE, 値 200112L の _POSIX_C_SOURCE (バージョン 2.5 よ
り 前の glibc では値は 199506L), 値 600 の _XOPEN_SOURCE (バージ
ョン 2.2 より前の glibc では値は 500)。さらに、各種の GNU 固有の
拡 張も公開される。指定された標準に矛盾があった場合は、 BSD 由来
の定義が優先されなくなる。
_REENTRANT
このマクロを定義すると、いくつかのリエントラント (再入可能) な関
数定義が公開される。マルチスレッド・プログラムでは、この代わりに
cc -pthread を使用すること。
_THREAD_SAFE
_REENTRANT の同義語。他のいくつかの実装との互換性を提供するた め
のもの。
_FORTIFY_SOURCE (glibc 2.3.4 以降)
このマクロを定義すると、文字列やメモリの操作を行う様々な関数を使
用する際にバッファオーバーフローを検出するための軽めのチェックが
実行されるようになる。すべてのバッファオーバーフローが検出される
わけではなく、あくまでよくある例についてだけである。現在の実装で
は、以下の関数にチェックが追加されている: memcpy(3), mempcpy(3),
memmove(3), memset(3), stpcpy(3), strcpy(3), strncpy(3), str-
cat(3), strncat(3), sprintf(3), snprintf(3), vsprintf(3),
vsnprintf(3), gets(3). _FORTIFY_SOURCE が 1 に設定された場合 、
コ ンパイラの最適化レベルが 1 (gcc -O1) かそれ以上であれば、規格
に準拠するプログラムの振る舞いを変化させないようなチェックが実行
される。 _FORTIFY_SOURCE が 2 に設定された場合、さらなるチェック
が追加されるが、規格に準拠するプログラムのいくつかが失敗する可能
性がある。いくつかのチェックはコンパイル時に実行でき、コンパイラ
の警告として表示される。他のチェックは実行時に行われ、チェックに
失敗した場合には実行時エラーとなる。このマクロを使用するにはコン
パイラの対応が必要であり、バージョン 4.0 以降の gcc(1) で利用 で
きる。
デフォルトの定義、暗黙の定義、組み合わせ定義
機 能検査マクロが一つも明示的に定義されなかった場合、デフォルトで機能検
査 マ ク ロ _BSD_SOURCE, _SVID_SOURCE, _POSIX_SOURCE,
_POSIX_C_SOURCE=200112l が定義される (バージョン 2.4 より前の glibc で
は _POSIX_C_SOURCE は 199506L となる)。
__STRICT_ANSI__, _ISOC99_SOURCE, _POSIX_SOURCE, _POSIX_C_SOURCE,
_XOPEN_SOURCE, _XOPEN_SOURCE_EXTENDED, _BSD_SOURCE, _SVID_SOURCE のいず
れかが明示的に定義された場合、 _BSD_SOURCE と _SVID_SOURCE はデフォルト
では定義されない。
_POSIX_SOURCE と _POSIX_C_SOURCE が 明 示 的に定義されない場合で、
__STRICT_ANSI__ が定義されない、もしくは _XOPEN_SOURCE が 500 以上の 値
で定義されたときには、
* _POSIX_SOURCE が値 1 で定義され、かつ
* _POSIX_C_SOURCE は以下の値のいずれか一つで定義される。
· 2 (_XOPEN_SOURCE が 500 未満の値で定義された場合)
· 199506L (_XOPEN_SOURCE が 500 以上 600 未満の値で定義された
場合)
· 200112L (バージョン 2.4 より 前 の glibc で は 199506L)
(_XOPEN_SOURCE が 600 以上の値で定義された場合)
ま た、複数のマクロを定義することもできる。この場合、定義したマクロはす
べて有効になる。
準拠
POSIX.1 では _POSIX_C_SOURCE, _POSIX_SOURCE, _XOPEN_SOURCE が規定されて
いる。 _XOPEN_SOURCE_EXTENDED は XPG4v2 (別名 SUSv1) で規定されていた。
_FILE_OFFSET_BITS はどの標準でも規定されていないが、他のいくつかの実 装
で採用されている。
_BSD_SOURCE, _SVID_SOURCE, _ATFILE_SOURCE, _GNU_SOURCE, _FOR-
TIFY_SOURCE, _REENTRANT, _THREAD_SAFE は Linux (glibc) 固有である。
注意
は Linux/glibc 固有のヘッダファイルである。他のシステム に
も 同様の目的のファイルがあるが、普通は違う名前である。このヘッダファイ
ルは、他のヘッダファイルにより必要に応じて自動的にインクルードされる 。
機能検査マクロを利用するために明示的にインクルードする必要はない。
上記の機能検査マクロのうちどれが定義されたかにしたがって、
は、他の glibc ヘッダファイルでチェックされる各種の他のマクロを、内部で
定 義 す る 。 これらのマクロの名前はアンダースコア 2つで始まる (例えば
__USE_MISC)。ユーザプログラムはこれらのマクロを 決して 直接定義すべきで
は ない。代わりに、上記のリストにある適切な機能検査マクロを利用すべきで
ある。
関連項目
libc(7), standards(7)
info libc の "Feature Test Macros" の節。
/usr/include/features.h
Linux 2008-01-02 FEATURE_TEST_MACROS(7)
FEATURE_TEST_MACROS(7) Linux Programmer’s Manual FEATURE_TEST_MACROS(7)
NAME
feature_test_macros - feature test macros
SYNOPSIS
#include
DESCRIPTION
Feature test macros allow the programmer to control the definitions
that are exposed by system header files when a program is compiled.
This can be useful for creating portable applications, by preventing
non-standard definitions from being exposed. Other macros can be used
to expose non-standard definitions that are not exposed by default.
The precise effects of each of the feature test macros described below
can be ascertained by inspecting the header file.
In order to be effective, a feature test macro must be defined before
including any header files. This can either be done in the compilation
command (cc -DMACRO=value) or by defining the macro within the source
code before including any headers.
Specification of feature test macro requirements in manual pages
When a function requires that a feature test macro is defined, the man-
ual page SYNOPSIS typically includes a note of the following form (this
example from the chmod(2) manual page):
#include
int chmod(const char *path, mode_t mode);
int fchmod(int fd, mode_t mode);
Feature Test Macro Requirements for glibc (see fea-
ture_test_macros(7)):
fchmod(): _BSD_SOURCE || _XOPEN_SOURCE >= 500
The || means that in order to obtain the declaration of fchmod(2) from
, either of the following macro definitions must be made
before including any header files:
#define _BSD_SOURCE
#define _XOPEN_SOURCE 500 /* or any value > 500 */
Alternatively, equivalent definitions can be included in the compila-
tion command:
cc -D_BSD_SOURCE
cc -D_XOPEN_SOURCE=500 # 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 SYNOPSIS.
In a few cases, manual pages use a shorthand for expressing the feature
test macro requirements (this example from readahead(2)):
#define _GNU_SOURCE
#include
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 following paragraphs explain how feature test macros are handled in
Linux glibc 2.x, x > 0.
Linux glibc understands the following feature test macros:
__STRICT_ANSI__
ISO Standard C. This macro is implicitly defined by gcc(1) when
invoked with, for example, 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 exposes def-
initions corresponding to the POSIX.1-2001 base specification
(excluding the XSI extension).
· (Since glibc 2.10) The value 200809L or greater exposes defi-
nitions 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.
_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).
_XOPEN_SOURCE_EXTENDED
If this macro is defined, and _XOPEN_SOURCE is defined, then
expose definitions corresponding to the XPG4v2 (SUSv1) UNIX
extensions (UNIX 95). This macro is also implicitly defined if
_XOPEN_SOURCE is defined with a value of 500 or more.
_ISOC99_SOURCE
Exposes C99 extensions to ISO C (1990). This macro is recog-
nized since glibc 2.1.3; earlier glibc 2.1.x versions recognized
an equivalent macro named _ISOC9X_SOURCE (because the C99 stan-
dard had not then been finalized). Although the use of the lat-
ter macro is obsolete, glibc continues to recognize it for back-
wards compatibility.
_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/plat-
form/lfs.html.) The alternative API consists of a set of new
objects (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 interface; instead
_FILE_OFFSET_BITS=64 should be employed.
_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 file system 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 recom-
pilation being required.) 64-bit systems naturally permit file
sizes greater than 2 Gigabytes, and on those systems this macro
has no effect.
_BSD_SOURCE
Defining this macro with any value causes header files to expose
BSD-derived definitions. Defining this macro also causes BSD
definitions 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_EXTENDED, or
_GNU_SOURCE is defined, in which case BSD definitions are disfa-
vored.
_SVID_SOURCE
Defining this macro with any value causes header files to expose
System V-derived definitions. (SVID == System V Interface Defi-
nition; see standards(7).)
_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).
_GNU_SOURCE
Defining this macro (with any value) is equivalent to defining
_BSD_SOURCE, _SVID_SOURCE, _ATFILE_SOURCE, _LARGEFILE64_SOURCE,
_ISOC99_SOURCE, _XOPEN_SOURCE_EXTENDED, _POSIX_SOURCE,
_POSIX_C_SOURCE with the value 200809L (200112L in glibc ver-
sions before 2.10; 199506L in glibc versions 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. Where standards conflict, BSD definitions are
disfavored.
_REENTRANT
Defining this macro exposes definitions of certain reentrant
functions. For multithreaded programs, use cc -pthread instead.
_THREAD_SAFE
Synonym for _REENTRANT, provided for compatibility with some
other implementations.
_FORTIFY_SOURCE (since glibc 2.3.4)
Defining this macro causes some lightweight checks to be per-
formed to detect some buffer overflow errors when employing
various string and memory manipulation functions. Not all
buffer overflows are detected, just some common cases. In the
current implementation checks are added for calls to memcpy(3),
mempcpy(3), memmove(3), memset(3), stpcpy(3), strcpy(3),
strncpy(3), strcat(3), strncat(3), sprintf(3), snprintf(3),
vsprintf(3), vsnprintf(3), and gets(3). 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 programs might fail.
Some of the checks can be performed at compile time, 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) 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, _SVID_SOURCE,
_POSIX_SOURCE, and _POSIX_C_SOURCE=200909L (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, _POSIX_SOURCE,
_POSIX_C_SOURCE, _XOPEN_SOURCE, _XOPEN_SOURCE_EXTENDED, _BSD_SOURCE, or
_SVID_SOURCE is explicitly defined, then _BSD_SOURCE, and _SVID_SOURCE
are not defined by default.
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
2001212L 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).
_FILE_OFFSET_BITS is not specified by any standard, but is employed on
some other implementations.
_BSD_SOURCE, _SVID_SOURCE, _ATFILE_SOURCE, _GNU_SOURCE, _FOR-
TIFY_SOURCE, _REENTRANT, and _THREAD_SAFE are specific to Linux
(glibc).
NOTES
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, internally defines 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.
EXAMPLE
The program below can be used to explore how the various feature test
macros are set depending 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
#include
#include
int
main(int argc, char *argv[])
{
#ifdef _POSIX_SOURCE
printf("_POSIX_SOURCE defined\n");
#endif
#ifdef _POSIX_C_SOURCE
printf("_POSIX_C_SOURCE defined: %ldL\n", (long) _POSIX_C_SOURCE);
#endif
#ifdef _ISOC99_SOURCE
printf("_ISOC99_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 _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), standards(7)
The section "Feature Test Macros" under info libc.
/usr/include/features.h
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2009-04-03 FEATURE_TEST_MACROS(7)