c - __WORDSIZE 在编译中的作用

标签 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

提前致谢。

最佳答案

它是一个 list 常量,供编译器实现独占内部使用;它的名称以两个下划线为前缀,这清楚地表明它不适合在用户空间中使用。

关于c - __WORDSIZE 在编译中的作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30728608/

相关文章:

linux - 如何使 wc 在没有 FIND 的情况下递归工作

linux - LS 命令未在 Amazon EC2 中列出文件

c++ - 基于范围的 for 循环从 1 而不是 0 开始?

linux - Ubuntu VM 上 Docker 容器中的假输入设备

c++ - MinGW/Eclipse ld.exe 找不到库

c++ - 在 Codeblocks 中构建时出现 MinGW 的 ar.exe "could not create temporary file whilst writing archive: no more archived files"错误

c - "Pure"用于碰撞检测目的的 C 四叉树

c - 如何在 Windows 上运行 Pthreads

c - 使用结构和 malloc 时为 "error: conversion to non-scalar type requested"

c - 删除 C 中的非字母字符