セカイ内存在証明

それは多分、単なる思い付き

読み込んでるヘッダーファイルの一覧を表示したりする方法

gcc -Hとするといいらしい。

例えばこういうソースコードがあったとする。

example.c

#include <stdio.h>

int main(int argc, char** argv) {
  long long fmt = 2851528194945829L;
  long long hello = 48857072035144L;
  long long world = 431316168535L;
  printf(&fmt, &hello, &world);

  return 0;
}

至って普通のHello, Wolrld!プログラムですね。はい。

これを、gcc -H -o example example.cとしてコンパイルすると、こんな感じになる。

. /usr/include/stdio.h
.. /usr/include/features.h
... /usr/include/x86_64-linux-gnu/sys/cdefs.h
.... /usr/include/x86_64-linux-gnu/bits/wordsize.h
... /usr/include/x86_64-linux-gnu/gnu/stubs.h
.... /usr/include/x86_64-linux-gnu/gnu/stubs-64.h
.. /usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h
.. /usr/include/x86_64-linux-gnu/bits/types.h
... /usr/include/x86_64-linux-gnu/bits/wordsize.h
... /usr/include/x86_64-linux-gnu/bits/typesizes.h
.. /usr/include/libio.h
... /usr/include/_G_config.h
.... /usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h
.... /usr/include/wchar.h
... /usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdarg.h
.. /usr/include/x86_64-linux-gnu/bits/stdio_lim.h
.. /usr/include/x86_64-linux-gnu/bits/sys_errlist.h
example.c: In function ‘main’:
example.c:7:3: warning: passing argument 1 of ‘printf’ from incompatible pointer type [enabled by default]
   printf(&fmt, &hello, &world);
   ^
In file included from example.c:1:0:
/usr/include/stdio.h:362:12: note: expected ‘const char * __restrict__’ but argument is of type ‘long long int *’
 extern int printf (const char *__restrict __format, ...);
            ^
Multiple include guards may be useful for:
/usr/include/wchar.h
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h
/usr/include/x86_64-linux-gnu/bits/typesizes.h
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h
/usr/include/x86_64-linux-gnu/gnu/stubs.h

中の方になんか警告が出てますがそれは無視するとして‥‥。

ほぇー、#include <stdio.h>しかインクルードはないのに内部ではこんなに色んなファイルをインクルードしてるんだなー。とか分かります。

最後に、念のために、

$ ./example
Hello, World!

ほらね、やっぱりHello, World!プログラムじゃないですか。