wrong version of gcc being used
For macOS Clang is a more preferred option (Apple stopped shipping gcc with Xcode and replaced it with Clang and the last version of GCC they supported was 4.2.1, it'll overall be more intuitive.). I'd remove GCC and do the following:
Installation of Clang

Run brew update and then brew upgrade in terminal
Run brew install llvm to install LLVM and Clang

To put Clang within your PATH variables:
echo 'export PATH=&quot;/usr/local/opt/llvm/bin:$PATH&quot;' &gt;&gt; ~/.bash_profile

I'm not too sure how different the two are when it comes to compiling (although they are probably very similar.) you can proceed with this link to catch up on the commands you'll need to use instead.