GCC代表GNU编译器集合,主要用于编译C和C++语言。它也可以用来编译Objective C和Objective C++。编译源代码文件时,最重要的选项是源程序的名称,其余每个参数都是可选的,例如警告,调试,链接库,目标文件等。GCC命令的不同选项允许用户停止编译过程处于不同阶段。
g ++命令是GNU C++编译器调用命令,用于对源代码进行预处理,编译,汇编和链接以生成可执行文件。 g ++命令的不同“选项”使我们可以在中间阶段停止此过程。
g ++和gcc之间的差异
g++ | gcc |
---|---|
g++ is used to compile C++ program. | gcc is used to compile C program. |
g++ can compile any .c or .cpp files but they will be treated as C++ files only. | gcc can compile any .c or .cpp files but they will be treated as C and C++ respectively. |
Command to compile C++ program through g++ is g++ fileName.cpp -o binary |
command to compile C program through gcc is gcc fileName.c -o binary |
Using g++ to link the object files, files automatically links in the std C++ libraries. | gcc does not do this. |
g++ compiles with more predefined macros. | gcc compiles C++ files with more number of predefined macros. Some of them are #define __GXX_WEAK__ 1, #define __cplusplus 1, #define __DEPRECATED 1, etc |