__WORDSIZE在编译中的作用

时间:2015-06-09 09:48:12

标签: c linux mingw

以下是/usr/include/x86_64-linux-gnu/gnu/stubs-32.h文件的内容:

#include <bits/wordsize.h>    
#if __WORDSIZE == 32
# include <gnu/stubs-32.h>
#elif __WORDSIZE == 64
# include <gnu/stubs-64.h>
#else
# error "unexpected value for __WORDSIZE macro"
#endif

我在64位机器上,所以

的结果
#include<stdio.h>
main()
{
printf("Word size : %d\n",__WORDSIZE);
}

Word size : 64

所以这就是问题,系统变量__WORDSIZE的作用是什么? 我正在开发一个32位应用程序(使用mingw 32位编译器),因为我的__WORDSIZE是64位,文件/usr/include/x86_64-linux-gnu/gnu/stubs-32.h最终会导致包含/usr/include/x86_64-linux-gnu/gnu/stubs-64.h。我对这部分感到困惑。这个行动有什么后果?这是正常的,如果不是,我怎么能强行包括/usr/include/x86_64-linux-gnu/gnu/stubs-32.h

提前谢谢你。

1 个答案:

答案 0 :(得分:5)

它是一个清单常量,供编译器实现专门用于内部使用;它的名称以两个下划线为前缀,这是一个明确的指示,它不适合在用户空间中使用。