harry_he 发表于 2010-03-19 11:13

如何判断编译时glibc中某个宏在哪里定义的?

我在编译native u-boot的时候,碰到vdprintf没有定义的问题,后来发现是因为宏__USE_XOPEN2K8没有打开的原因,但是这个宏只在glibc中使用了,u-boot并没有使用它,而且应不应该去使用它。如果使用交叉编译器没有这样的问题,__USE_XOPEN2K8似乎被定义了。那么我如何检查这个宏到底是在哪里定义的呢?gcc会传递一些缺省宏吧?glibc也有一些宏是打开的。有没有办法可以列出编译过程中哪些宏被打开了?

qtdszws 发表于 2010-03-19 14:51


# cat 1.c
#define A 1
#undef A

# gcc -E -dD 1.c
# 1 "1.c"
# 1 "<built-in>"
#define __VERSION__ "3.2.2 20030222 (Red Hat Linux 3.2.2-5)"
#define __USER_LABEL_PREFIX__
#define __REGISTER_PREFIX__
#define __HAVE_BUILTIN_SETJMP__ 1
#define __SIZE_TYPE__ unsigned int
#define __PTRDIFF_TYPE__ int
#define __WCHAR_TYPE__ long int
#define __WINT_TYPE__ unsigned int
#define __STDC__ 1
# 1 "<command line>"
#define __GNUC__ 3
# 1 "<command line>"
#define __GNUC_MINOR__ 2
# 1 "<command line>"
#define __GNUC_PATCHLEVEL__ 2
# 1 "<command line>"
#define __GXX_ABI_VERSION 102
# 1 "<command line>"
#define __ELF__ 1
# 1 "<command line>"
#define unix 1
# 1 "<command line>"
#define __gnu_linux__ 1
# 1 "<command line>"
#define linux 1
# 1 "<command line>"
#define __ELF__ 1
# 1 "<command line>"
#define __unix__ 1
# 1 "<command line>"
#define __gnu_linux__ 1
# 1 "<command line>"
#define __linux__ 1
# 1 "<command line>"
#define __unix 1
# 1 "<command line>"
#define __linux 1
# 1 "<command line>"
#define __NO_INLINE__ 1
# 1 "<command line>"
#define __STDC_HOSTED__ 1
# 1 "<command line>"
#define i386 1
# 1 "<command line>"
#define __i386 1
# 1 "<command line>"
#define __i386__ 1
# 1 "<command line>"
#define __tune_i386__ 1
# 1 "1.c"
#define A 1
#undef A
# gcc -E -dM 1.c
#define __HAVE_BUILTIN_SETJMP__ 1
#define __unix__ 1
#define unix 1
#define __i386__ 1
#define __SIZE_TYPE__ unsigned int
#define __ELF__ 1
#define __GNUC_PATCHLEVEL__ 2
#define __linux 1
#define __unix 1
#define __linux__ 1
#define __USER_LABEL_PREFIX__
#define linux 1
#define __STDC_HOSTED__ 1
#define __WCHAR_TYPE__ long int
#define __gnu_linux__ 1
#define __WINT_TYPE__ unsigned int
#define __GNUC__ 3
#define __GXX_ABI_VERSION 102
#define i386 1
#define __GNUC_MINOR__ 2
#define __STDC__ 1
#define __PTRDIFF_TYPE__ int
#define __tune_i386__ 1
#define __REGISTER_PREFIX__
#define __NO_INLINE__ 1
#define __i386 1
#define __VERSION__ "3.2.2 20030222 (Red Hat Linux 3.2.2-5)"

harry_he 发表于 2010-03-24 16:13

谢谢,真得很有用
页: [1]
查看完整版本: 如何判断编译时glibc中某个宏在哪里定义的?