【发布时间】:2020-10-26 22:20:58
【问题描述】:
我一直在为我计划的一些即将进行的项目组合一个 m68k 交叉编译“环境/工具链”,但我在 macOS(我的原生环境)上使用它时遇到了问题。
如果我按照自己的说明在 Linux (https://github.com/tomstorey/m68k_bare_metal/blob/master/INSTALL-Debian-Ubuntu.md) 上安装,那么在我的代码中,我可以通过 #include <stdint.h> 使用诸如 uint8_t 等类型。
但是如果我在 macOS 上安装并尝试做同样的事情,我会收到这个错误:
In file included from main.c:1:
/Users/tstorey/m68k/m68k-unknown-elf/lib/gcc/m68k-unknown-elf/9.3.0/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory
9 | # include_next <stdint.h>
| ^~~~~~~~~~
compilation terminated.
make: *** [main.o] Error 1
我已经做了一些搜索,但我没有找到答案,也许是因为我真的不知道除了“stdint.h not found”之外要搜索什么。
我确实发现了一个主题建议 include_next 真的不应该使用,但同一个人不建议修改原始的 stdint.h 文件来解决它。大概因为在这种情况下它包含<stdint.h>,那么这个文件应该位于“系统明智”的某个地方,gcc 应该知道在哪里可以找到它?但大概那个位置不存在。
在我试图包含的stdint.h 文件所在的同一目录中,有一个stdint-gcc.h 文件,如果我将它包含在我的代码中,它将编译得很好,不用担心。
原始的stdint.h 文件似乎确实试图包含此文件,但前提是未定义__STDC_HOSTED__:
$ cat stdint.h
#ifndef _GCC_WRAP_STDINT_H
#if __STDC_HOSTED__
# if defined __cplusplus && __cplusplus >= 201103L
# undef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
# undef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
# endif
# include_next <stdint.h>
#else
# include "stdint-gcc.h"
#endif
#define _GCC_WRAP_STDINT_H
#endif
对不起,如果这篇文章有点笨拙,但我对gcc 等的经验还不够,无法真正解决这个问题,而且我还在学习很多关于设置所有这些的知识,所以我想知道是否有人知道我错过了什么。
谢谢
【问题讨论】: