2

I've tried to replace the included gcc 4.2.1 compiler on my Mac Book Pro with latest version of Mac OSX but can't figure out what Im doing wrong:

Also this screen scrape from my shell doesn't make sense for me:

Johans-MBP:bin johanlindfors$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1 Apple LLVM version 10.0.0 (clang-1000.11.45.5) Target: x86_64-apple-darwin18.2.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Johans-MBP:bin johanlindfors$ which gcc
/usr/local/bin/gcc
Johans-MBP:bin johanlindfors$ /usr/local/bin/gcc --version
gcc (Homebrew GCC 8.2.0) 8.2.0 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Johans-MBP:bin johanlindfors$

  • Try running `type gcc` to see if you have an alias or function defined. – Mark Setchell Dec 08 '18 at 09:31
  • Try also `hash -r` to make your shell rehash its tables. – Mark Setchell Dec 08 '18 at 09:36
  • The system gcc-4.2.1 compiler is a legacy of the change over to clang. I should never be used for your own code. Edit your `.profile` or `.tcshrc` to prepend the newer gcc directory to the path. Or save a lot of time and energy and use [MacPorts](https://www.macports.org). – Brett Hale Dec 13 '18 at 14:08

2 Answers2

1

It's because it's actually Apple Clang pretending to be GCC.

1

The system gcc-4.2.1 compiler is a (very old) legacy of the migration from the gcc to clang compilers. It should never be used for your own code. Edit your .profile or .tcshrc to prepend the newer gcc directory to the path. Or save a lot of time and energy and use MacPorts.

Unfortunately, Clang has established 'absolute' compatibility at gcc-4.2.1: see: clang -E -dM - < /dev/null | grep GNU

That's not a bad thing. Once the compiler gains traction it's going to provide it's own extensions, and no longer track those of others. Many extensions remain compatible like Intel's <x86intrin.h>. It's not really in either compiler's interests to provide too much divergence with extensions...

The 'stable' gcc is now 8.2.0 according to MacPorts. The stable MacPorts clang (which irritably conflicts with OS X) is apparently 7.0.0 ... short story - don't go replacing sets of files arbitrarily that you think might work. Then set up paths correctly - IIRC, MacPorts will do this for you.

I provided a more recent summary: here.

Brett Hale
  • 21,653
  • 2
  • 61
  • 90