【问题标题】:stdio.h: No such file or directorystdio.h:没有这样的文件或目录
【发布时间】:2020-01-25 22:09:37
【问题描述】:

我明白了。编译一个简单的ciao.c program时出错

 In file included from ciao.c:1:
/usr/local/lib/gcc/x86_64-apple-darwin18.5.0/8.3.0/include-fixed/stdio.h:78:10: fatal error: _stdio.h: No such file or directory
 #include <stdio.h>
          ^~~~~~~~~~
compilation terminated.

我已经安装了 Xcode、命令行工具和你想要的,但是没有。

#include <stdio.h>
int main()
{
    printf("Hello, World!");
    return 0;
}

你能帮帮我吗?

【问题讨论】:

  • 使用这个#include &lt;stdio.h&gt;
  • 检查Can't compile C program on a Mac after upgrade to Mojave——它可能会对你有所帮助。
  • 您似乎使用的是“真实的”gcc(而不是 XCode 中的 gcc,实际上是伪装的 clang(/usr/bin/gcc --version 可能会产生 Apple clang version 11.0.0 (clang-1100.0.33.8) — Target: x86_64-apple-darwin18.7.0 或类似的东西) (来自 XCode 11.0)。错误消息来自“真正的”GCC。它表明 /usr/include 中存在问题 — 在我的机器上 /usr/include 下有三个文件 _stdio.h(在 /usr/include 中,@ 987654335@ 和 /usr/include/secure) — 也许其他问题会对您有所帮助。

标签: c xcode macos gcc stdio


【解决方案1】:

将&lt;_stdio.h&gt; 重命名为&lt;stdio.h&gt;。

附:以下是对更新问题的更新答案:

尝试使用 xcode-select --install 重新安装 Xcode。

【讨论】:

  • 没有<_stdio.h>
【解决方案2】:

其实我也遇到了和你一样的问题;这是步骤,按照它来,可能对你有帮助

选择1:每次打开终端时复制粘贴以下内容

export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include

选择 2:如果选择 1 有效,则:

步骤一:将以下代码粘贴到终端:

open /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include

第二步:打开一个新终端,粘贴以下代码:

open /usr/local/lib/gcc/x86_64-apple-darwin18.5.0/8.3.0/include-fixed/

Step-3:从step-1复制所有文件文件,您打开的方向(包括)->粘贴到step-2,你打开的方向(包括固定)

第 4 步: 当它询问您是否要替换文件时,请选择替换。

【讨论】:

    猜你喜欢
    • 2010-09-10
    • 1970-01-01
    • 2013-11-04
    • 2021-04-29
    • 2014-05-25
    • 2021-06-24
    • 2023-03-30
    • 2015-02-20
    相关资源
    最近更新 更多