2

I searched a little bit and one google search was enough to discover the differences between the gcc and cc compilers, but I did not find the advantages in using one or another to compile C programs

Which compiler should I use? and why?

10
  • 4
    What does cc --version report and what does gcc --version report? Commented Dec 30, 2021 at 13:48
  • Apple clang version 13.0.0 (clang-1300.0.29.30) \n Target: arm64-apple-darwin21.2.0 \n Thread model: posix \n InstalledDir: /Library/Developer/CommandLineTools/usr/bin Commented Dec 30, 2021 at 13:49
  • i used \n to indicate where are the line breaks Commented Dec 30, 2021 at 13:49
  • 1
    If gcc reports the same as cc something must have gone wrong upon installation. gcc is not a clang based compiler. Commented Dec 30, 2021 at 13:50
  • 2
    On Apple, gcc is a link to clang. Commented Dec 30, 2021 at 13:52

1 Answer 1

1

The compiler installed as part of X-Code on OS/X is a recent version of clang whose development is sponsored by Apple.

gcc is not provided nor supported by Apple.

Unless you install gcc explicitly from one of its distributions, gcc is an alias for clang on OS/X, just like cc.

The reason for this is to support packages that use gcc explicitly as the C compiler.

On your system, it does not matter which alias you use, the compiler invoked will be clang, which has a high degree of compatibility with gcc extensions but generates different code. Both are very advanced and dependable.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.