簡體   English   中英

stdint.h include_next'd from stdint.h not found

[英]stdint.h include_next'd from stdint.h not found

我一直在為我計划的一些即將到來的項目組合一個 m68k 交叉編譯“環境/工具鏈”,我在 macOS(我的原生環境)上使用它時遇到了問題。

如果我按照自己的說明在 Linux 上安裝( https://github.com/tomstorey/m68k_bare_metal/blob/master/INSTALL-Debian-Ubuntu.md ),那么在我的代碼中我可以使用諸如uint8_t之類的類型通過#include <stdint.h>

但是,如果我在 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等的經驗還不夠,無法真正解決這個問題,而且我仍在學習很多關於設置所有這些的知識,所以我想知道是否有人知道我已經錯過了。

謝謝

當您的特定版本的 gcc 已構建時,它顯然不是為托管環境構建的(即標准 C 庫的完全可用性,例如newlib )。 在這種情況下,您不能期望標准庫支持並且只能靠自己。

您可能希望使用newlib支持重新構建 gcc。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM