What is difference between GCC and G++ Compilers?

C++Server Side ProgrammingProgramming

We use gcc and g++ compilers in different times. Here we will see what are the differences between gcc and g++.

The gcc is GNU C compiler, and g++ is GNU C++ compiler. The main differences are like below −

  • gcc can compile *.c or *.cpp files as C and C++ respectively
  • g++ can also compile *.c and *.cpp files, but take both as C++ file
  • If we want to use g++ to link the object files, it automatically links in the STD C++ libraries. The gcc does not do that
  • gcc compiles C files which has fewer predefined macros
  • gcc compiles C++ files with more number of predefined macros, and also g++ compiles with more predefined macros.

The extra macros for C++ files are like below −

#define __GXX_WEAK__ 1
#define __cplusplus 1
#define __DEPRECATED 1
#define __GNUG__ 4
#define __EXCEPTIONS 1
#define __private_extern__ extern
Published on 08-May-2019 08:46:10