2

I got the foll. error compiling a simple 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.

I've already installed Xcode, command line tools and what you want, but nope.

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

Could you help me please?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Nico Battelli
  • 61
  • 1
  • 2
  • 7
  • use this `#include ` – Kalana Sep 25 '19 at 16:55
  • 1
    Check [Can't compile C program on a Mac after upgrade to Mojave](https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave/52530212#52530212) — it will likely help you. – Jonathan Leffler Sep 25 '19 at 18:12
  • 1
    You seem to be using a 'real' `gcc` (as opposed to the `gcc` from XCode which is actually `clang` in disguise (`/usr/bin/gcc --version` likely produces `Apple clang version 11.0.0 (clang-1100.0.33.8) — Target: x86_64-apple-darwin18.7.0` or something similar (that's from XCode 11.0). The error message is from 'real' GCC. It suggests that there is a problem in `/usr/include` — there are three files `_stdio.h` under `/usr/include` on my machine (in `/usr/include`, `/usr/include/xlocale` and `/usr/include/secure`) — and maybe the other question will help you. – Jonathan Leffler Sep 25 '19 at 18:23

2 Answers2

3

Rename <_stdio.h> to <stdio.h>.

P.S. Here is an updated answer to the updated question:

Try reinstalling Xcode using xcode-select --install.

John
  • 1,012
  • 14
  • 22
3

I actually have the same issue that you have;here is the step, follow it, it may help you

choose 1: Copy and paste the following every time you open the terminal

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

choose 2: If the choose 1 is working then:

Step-1: Paste the following code in terminal:

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

Step-2: Open a new terminal, paste the following code:

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

Step-3: copy All file file from step-1, the direction(include) you have open -> paste in the step-2, the direction(include-fixed) you open

Step 4: When it asks you about whether to REPLACE the file or not, choose to replace.

CKE
  • 1,533
  • 19
  • 18
  • 29
Chener Zhang
  • 129
  • 9