gcc

gcc does not stand for gnu c compiler, it stands for gnu compiler collection. The name of the c compiler is cc. Often people you use gcc as a synonym for the c compiler, consider this a the default compiler. If you have Gentoo Linux all c source code will be passed through gcc therefore this is probably the program most used on your computer.

Get the CHOST, CFLAGS, CXXFLAGS settings for gcc stored in /etc/make.conf from https://wiki.gentoo.org/wiki/CFLAGS

If the CPU identifies itself the native can be used so gcc pick the CFLAGS depending on this :

CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}" 

gcc is rather complex and can create different outputs depending on its profiles. The program

gcc-config

lets you explore its configurations. Binaries compiled with different compiler versions can (but do not have to) create incompatibility problems (mainly libraries). On major compiler version updates (gcc3.x.x to gcc4.x.x) it is wise to spend a couple of (ten) hours to do a re-compilation of all the packages to have a clean Gentoo installation afterwards. See the last hope solution

Binary distributions need some not easy methods to deal with incompatibilities of programs and libraries to support binaries of different versions. It is a clear strength of Gentoo to not require such things (except for binary packages that Gentoo supports as well).

gcc-config -l

lists all gcc profiles, and should show the selected profile, after and update it can be happen that the selected profile gets lost, then just select manually a profile as:

gcc-config 2

switches to profile 2

gcc produces by default a.out

-o to have an other name

-c tells gcc to not link.

-g to add the debug data.

-Wall to generate all warnings

-i<dir> to include header files

Since gcc is a compile collection, it has many front ends for the different programming languages and many back ends to support different assembly languages of the hardware desired. Gcc is executed on host and produces code for a target. Is the host also the target then a native compiler is used if host is different from the target then a cross-compiler is used. Gcc uses the preprocessor (cpp), the C compiler (cc), the Gnu assembler (as) and the Gnu linker (ld). Additionally there is also Libc the Standard C Library.

The preprocessor could also be run standalone.

#define BUFFER 32

assigns the number 32 to the word (or in terms of cpp the macro) BUFFER. Macros are written in uppercase.

There are also predefined macros as __DATE__ and __TIME__ that hold date and time when the compilation run. There are the following directives: http://gcc.gnu.org/onlinedocs/cpp/Index-of-Directives.html#Index-of-Directives

#warning and #error can be used to print out information.

It is also possible to run gcc under windows, see: http://www.mingw.org/. Alternatively there are other free C compiler environments around as:

  1. Open watcom http://www.openwatcom.org/

  2. Codeblocks http://www.codeblocks.org/

gcc has a profile and this can be messed up and when running gcc a response appears as:

* gcc-config: Active gcc profile is invalid!

gcc-config: error: could not run/locate 'gcc'

This looks quite as a disaster for Gentoo, since without gcc nothing can be emerged. The profile can be recovered by calling:gcc-config i686-pc-linux-gnu-4.5.3 and therefore source /etc/profile and hopefully gcc-config -l is happy.


Linurs startpage