Why is the command for compiling C++ files g++?

i know it’s minor, but it seems like an odd choice to me

1 Like

Minor observation leads to serious discussion hahahha.

It’s actually not. The command for the compiling with the GCC compiler is g++. That’s the GNU Compiler Collection (https://gcc.gnu.org/)

You can compile with any other compiler you want. For example clang: https://clang.llvm.org/
The command for that one would be something like clang mySourceCode.cpp. There’s also Visual C++ from microsoft and many others.

You can think of C++ the language as a standard. It defines what should happen. Then there is something you’ll hear if you work with C++ that a certain behavior is “undefined”. This basically means that although one compiler may handle it one way, another will handle it another way, and there is not standard guarantee that the source code you just wrote will behave the same across the board. I ran into this when writing a cross-platform project with some people, we were using different compilers and learned the hard way that just because it compiles and runs with one doesn’t mean the same behavior will happen on a different compiler.