[26 Sep 2023]

Setting up your C++ command-line environment

First, make sure you have a proper (i.e., command line-based) environment to develop and test your code. Use whichever IDE you want but your code MUST work with g++ version >=13.
To test that everything works OK, copy-paste the following highlighted text in a Linux/WSL+Ubuntu/Mac terminal:

cd ; mkdir tst; cd tst
cat > Makefile << EOF_Makefile
CXXFLAGS=-std=c++20 -pedantic -Wall -Wpointer-arith -Wwrite-strings
CXXFLAGS+=-Wcast-qual -Wcast-align -Wformat-security
CXXFLAGS+=-Wformat-nonliteral -Wmissing-format-attribute
CXXFLAGS+=-Winline -funsigned-char
CC=\$(CXX)
EOF_Makefile
cat > hello.cc << EOF_Hello
#include <iostream>
using namespace std;
#define X(token) #token
int main() {
  cout << X(Hello) << char(32) << X(World) << char(33) << endl;
  return 0;
}
EOF_Hello
make hello && ./hello

Does it print "Hello World!"? With no warnings/errors? Congratulations, you're good to go!

If the above doesn't work, contact me ASAP!!! (and copy-paste - don't screenshot!1 - the output of g++ --version. Your compiler may be called g++-13 instead, so please do the same for g++-13 --version)

Quick solution for Linux(=WSL+Ubuntu)/MacOS – COPY-PASTE (***DON'T TYPE!***) THE FOLLOWING:

# On both: 1) Get brew (one line!!!):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# On Linux only: 1.5) Add brew to PATH (for default installation!!!):

eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.profile

# On both: 2) Install gcc@13:

brew install gcc

# On both: 3) Make sure g++-13 is the default (now & in the future):

export CXX=g++-13
echo export CXX=g++-13 >> ~/.profile
# Use the C++ compiler as the C compiler to avoid linking errors.
export CC=${CXX}
echo export 'CC=${CXX}' >> ~/.profile

Debugging Tips:

Your code should compile with no warnings using the Makefile file defined above (i.e., that set of compiler flags).

1 It's text, so copy-paste it, don't take a screenshot. In general, don't use images of code/results, use the proper text itself.