c - 在 Windows 中使 CC=other_cc
问题描述
也许这个问题很愚蠢,但我真的无法找到解决此问题的方法
$ make
x86_64-w64-mingw32-gcc -D OS_WINDOWS_NT -ansi -Wall -O2 -Wno-long-long -I /usr/include -c -o main.o main.c
In file included from /usr/include/sys/_pthreadtypes.h:12,
from /usr/include/sys/types.h:223,
from /usr/include/stdio.h:61,
from main.c:5:
/usr/include/sys/cpuset.h:17:30: error: expected expression before ‘/’ token
17 | #define __CPU_SETSIZE 1024 // maximum number of logical processors tracked
| ^
/usr/include/sys/cpuset.h:19:25: note: in expansion of macro ‘__CPU_SETSIZE’
19 | #define __CPU_GROUPMAX (__CPU_SETSIZE / __NCPUBITS) // maximum group number
| ^~~~~~~~~~~~~
/usr/include/sys/cpuset.h:26:21: note: in expansion of macro ‘__CPU_GROUPMAX’
26 | __cpu_mask __bits[__CPU_GROUPMAX];
| ^~~~~~~~~~~~~~
/usr/include/sys/cpuset.h:19:55: error: expected expression before ‘/’ token
19 | #define __CPU_GROUPMAX (__CPU_SETSIZE / __NCPUBITS) // maximum group number
| ^
/usr/include/sys/cpuset.h:26:21: note: in expansion of macro ‘__CPU_GROUPMAX’
26 | __cpu_mask __bits[__CPU_GROUPMAX];
| ^~~~~~~~~~~~~~
/usr/include/sys/cpuset.h:27:1: warning: no semicolon at end of struct or union
27 | } cpu_set_t;
| ^
In file included from /usr/include/errno.h:9,
from main.c:8:
/usr/include/sys/errno.h:14: warning: "errno" redefined
14 | #define errno (*__errno())
|
In file included from /usr/lib/gcc/x86_64-w64-mingw32/10/include/stddef.h:1,
from /usr/include/sys/cdefs.h:47,
from /usr/include/stdio.h:35,
from main.c:5:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/stddef.h:19: note: this is the location of the previous definition
19 | #define errno (*_errno())
|
make: *** [<builtin>: main.o] Error 1
解决方案
您的问题是您已将-ansi
选项添加到编译行:
x86_64-w64-mingw32-gcc -D OS_WINDOWS_NT -ansi ...
该-ansi
选项告诉编译器编译您的代码,就好像它是 ANSI C 89 标准代码一样。该版本的标准不支持//
单行注释分隔符:它只支持传统/* ... */
注释。
但是,您包含的头文件显然希望能够使用//
注释。-ansi
因此,当您使用这些头文件进行编译时,您不能使用该标志。
推荐阅读
- c - 在 C 代码中对未排序文本文件的输出进行排序
- python - 在python中对一列求和
- python - 在python中查找两个数组的交集
- angular - 定位 cdk 覆盖时出错
- javascript - 无法使用视频控件播放来自 iframe 页面的 youtube 嵌入视频 iframe 是 youtube 视频的页面
- python - 使用 Python 和 Jupyter Notebook 向 reddit 帐户添加代理
- javascript - Puppeteer 抓取在 ubuntu 服务器 18.04 上不起作用
- php - 如何在 Docker 中从 PECL 存储库安装(致命错误:不再支持带花括号的数组和字符串偏移访问语法)
- r - 从区间中查找特定元素的总和(需要模拟)
- python - AssertionError:没有产生任何示例