What is the difference between g++ and gcc? Which one of them should be used for general c++ development?
GCC: GNU Compiler Collection
gcc
: GNU C Compiler
g++
: GNU C++ Compiler
The main differences:
gcc
will compile: *.c\*.cpp
files as C and C++ respectively.g++
will compile: *.c\*.cpp
files but they will all be treated as C++ files.g++
to link the object files it automatically links in the std C++ libraries (gcc
does not do this).gcc
compiling C files has fewer predefined macros.gcc
compiling *.cpp
and g++
compiling *.c\*.cpp
files has a few extra macros.Extra Macros when compiling *.cpp
files:
#define __GXX_WEAK__ 1
#define __cplusplus 1
#define __DEPRECATED 1
#define __GNUG__ 4
#define __EXCEPTIONS 1
#define __private_extern__ extern