LoginSignup
2
2

More than 5 years have passed since last update.

ヘッダ内で定義済みマクロ一覧を取得する方法

Posted at

cpp -dM を使います。

$ printf '#include <sys/stat.h>' | cpp -dM - | head -5
#define __S_IFBLK 0060000
#define S_ISCHR(mode) __S_ISTYPE((mode), __S_IFCHR)
#define __DBL_MIN_EXP__ (-1021)
#define __UINT_LEAST16_MAX__ 65535
#define __ATOMIC_ACQUIRE 2

マクロ定義を先につけるとプリプロセッサ実行時に適用されます。

$ printf '#include <sys/stat.h>' | cpp -dM - | wc -l
477
$ printf '#define _GNU_SOURCE\n#include <sys/stat.h>' | cpp -dM - | wc -l
495
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2