Cannot compile any C++ programs; error: unknown type name 'uint8_t' Cannot compile any C++ programs; error: unknown type name 'uint8_t' xcode xcode

Cannot compile any C++ programs; error: unknown type name 'uint8_t'


Maybe you can try:

mv /usr/local/include /usr/local/include.old

then:

brew install llvm


It's fairly obvious that you borked your system GCC installation. Please note that GCC is a suite of compilers and that G++ is the C++ front-end. Package managers often have a separate package called gcc-g++, however, when compiling from source, you simply do --enable-languages=c,c++. Now if reinstalling XCode doesn't resolve the problem (you should've already done this, if "it takes up too much space" just remove it), then you can try compiling GCC from source. Adapted from the GNU wiki:

  • First, grab your desired GCC tar ball from here

  • Untar it with tar zxvf gcc*

  • cd gcc* then ./contrib/download_prerequisites

  • Do an out of source build: mkdir build && cd build

  • ../gcc*/configure --prefix=$HOME/gcc-install --enable-languages=c,c++

  • make and make install

Now just add $HOME/gcc-install/bin to your path and you should be good to go.


I experienced this error during compilation of Perl-5.34.0 from source. An alternative solution that worked for me was setting the SDK environment variable:

export SDK=`xcrun --show-sdk-path`

Sometimes, you may need to set SDKROOT in the same way:

export SDKROOT=`xcrun --show-sdk-path`

Placing it into your ~/.profile file will (conveniently) make this setting permanent.