Last Update 2021/12/26
-nostdinc
ヘッダファイルを標準的なシステムディレクトリで検索しない
テスト概要
-nostdincオプションの有無によるヘッダファイル検索ディレクトリの比較
実行環境
GCC-8.2.0
GNU C Library 2.28
GNU Binutils 2.31.1
GNU C Library 2.28
GNU Binutils 2.31.1
コード例・出力内容中の表記
・実行例中の太字表記部分は、コマンドなどの入力された文字列を示します。
・「︙」や「...」の着色省略表記は、 実際のソースコードや出力内容などを省略加工した部分を示します。
・「︙」や「...」の着色省略表記は、 実際のソースコードや出力内容などを省略加工した部分を示します。
使用ファイル
使用ファイル一覧
.
+--header_dir_sample
| +--sample.h
|
+--sample.c
header_dir_sample/sample.h
#ifndef SAMPLE_H
#define SAMPLE_H
#define SAMPLE 1
#endif /* SAMPLE_H */
sample.c
#include <sample.h>
int main(void)
{
return 0;
}
動作テスト
-nostdincオプションの有無によるヘッダファイル検索ディレクトリの比較
-nostdincオプション無しで実行
$ gcc -v -I header_dir_sample sample.c
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 ...
︙
#include "..." search starts here:
#include <...> search starts here:
header_dir_sample
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include-fixed
/usr/include
End of search list.
︙
$ -Iオプションで指定(ピンク)、システムディレクトリ(青)が検索対象
-nostdincオプションを使用して実行
$ gcc -v -nostdinc -I header_dir_sample sample.c
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 ...
︙
#include "..." search starts here:
#include <...> search starts here:
header_dir_sample
End of search list.
︙
$ -Iオプションで指定(ピンク)したディレクトリのみが検索対象