【发布时间】:2018-12-29 23:40:59
【问题描述】:
我对 mac Mojave 10.14.1 上的 #include <stdio.h> 有疑问
我有一个默认的 gcc 编译器和其他 gcc 编译器。
DorothyeMacBook:Desktop dorothy$ which gcc
/usr/local/bin/gcc
版本是
DorothyeMacBook:Desktop dorothy$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin15.6.0/7.1.0/lto-wrapper
Target: x86_64-apple-darwin15.6.0
Configured with: ../gcc-7.1.0/configure --enable-languages=c++,fortran
Thread model: posix
gcc version 7.1.0 (GCC)
现在我在路上: /用户/dorothy/桌面
我在库中有 stdio.h
DorothyeMacBook:Desktop dorothy$ find /usr -name "stdio.h"
find: /usr/sbin/authserver: Permission denied
/usr/local/include/c++/7.1.0/tr1/stdio.h
/usr/local/include/c++/4.9.2/tr1/stdio.h
/usr/local/lib/gcc/x86_64-apple-darwin15.6.0/7.1.0/include/ssp/stdio.h
/usr/local/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/include/ssp/stdio.h
/usr/local/Cellar/gcc/8.2.0/include/c++/8.2.0/tr1/stdio.h
/usr/local/Cellar/gcc/8.2.0/lib/gcc/8/gcc/x86_64-apple-darwin18.2.0/8.2.0/include/ssp/stdio.h
/usr/local/Cellar/gcc/8.2.0/lib/gcc/8/gcc/x86_64-apple-darwin18.2.0/8.2.0/include-fixed/stdio.h
但是当我在当前路径/Users/dorothy/Desktop Terminal下编译文件时会给我一个错误:
DorothyeMacBook:Desktop dorothy$ gcc inverse.c -o inv
inverse.c:1:10: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^~~~~~~~~
compilation terminated.
【问题讨论】:
-
gcc仅针对 c++ 和 fortran 构建,但您正尝试将其用作c编译器,这似乎有点奇怪。如果您将inverse.c重命名为inverse.cpp是否有效? -
Configured with: ../gcc-7.1.0/configure --enable-languages=c++,fortran是的,这看起来很奇怪,我的列表中有c,没有它我无法判断是否支持stdio.h。从错误信息来看,我认为不是。 -
你安装了xcode吗?
-
@JonathanLeffler:你为什么认为我们是重复的?软件安装有很多方法可能会搞砸。那里的问题似乎是 Xcode/Apple 工具安装损坏。这个问题似乎涉及到一些 GCC 版本,这是不同的(Apple 现在使用 Clang)。
-
请参阅Can't compile C program on a Mac after upgrade to Mojave 以了解可能的解决方案。并非所有人都同意您的问题将通过那里的步骤解决,尽管我强烈怀疑您所看到的就是我所看到的,以及该问题的 OP 所看到的——系统标头已被 Apple 从
/usr/include中删除在升级到 Mojave 期间。
标签: c compiler-errors