I had to run the following cryptic commands to get my C compiler working in mac osx Mojave, after having everything working fine in a previous OS (Yosemite I think it was...)
This is an (somewhat) obvious step when upgrading osx:
xcode-select --install
I also had to do this, which I never would've known how to do without google and this post
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /