How to compiler the code with brew's GCC instead of Clang on MAC?

#1

Hi,all!
I use OSX(10.14.1 majove) to compile the code of PX4.I have installed gcc with brew.But it still compiles the code with apple’s LLVM.I have tried add
"export PATH=/usr/local/bin/gcc-8.2/bin:$PATH " to the bash_profile.And it doesn’t work.

How can I switch the compiler from LLVM to the brew’s gcc?Thank you!

here is the gcc’s version:
$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

#2

I think you should be able to set CC and CXX as described here:

So:

make clean
CC=gcc
CXX=g++
make <whatever>