Invoking GCC as "cc" versus "gcc"
I am aware that on most GNU/Linux systems, GCC can be invoked by the name "cc" from the command line (as opposed to "gcc"). Is there any difference in GCC's behavior when it is invoked one way versus the other?
For example, I know that invoking GCC through the name "g++" instead of "gcc" causes GCC to behave differently (it treats .c files as C++ source and links-in the C++ standard library). Is there any similar difference in behavior between "gcc" versus "cc"?
EDIT: None of the answers received so far gave a definitive "yes" or "no" as to whether GCC will behave differently if invoked one way versus the other. However, the idea given to dive into the source to check its behavior lead me down that path. Based upon what I found there, I now believe that the answer is:
No. GCC behaves the same regardless of whether it is called via "gcc" or "cc".
Solution 1:
For grins, I just traced down how argv[0]
is used from within gcc (main.c
-> top_lev.c
-> opts.c
-> langhooks.c
) and it appears that argv[0]
is currently used for nothing more than giving malloc
something to report when it fails. There doesn't appear to be any behavior change if argv[0]
is anything other than gcc
.
Solution 2:
It looks to me that cc
(link to some old SUS specification) is intended to be the vendor-neutral interface to the system's compiler. It's marked as legacy:
The c89 utility provides an interface to the ISO C standard, but the cc utility accepts an unspecified dialect of the C language: it may be Standard C, common-usage C or some other variant. Portable C programs should be written to conform to the ISO C standard and compiled with c89.
POSIX has a utility called c99
which I believe is the successor of c89
. It says
The c99 utility is based on the c89 utility originally introduced in the ISO POSIX-2:1993 standard. Some of the changes from c89 include the modification to the contents of the Standard Libraries section to account for new headers and options; for example, added to the -l rt operand, and the -l trace operand added for the Tracing functions.
I'm not really familiar to all those different standards, but it looks like the more recent SUSv3 (POSIX:2004) and the yet more recent POSIX:2008 (doesn't seem to have a SUS number yet) do not specify a utility called cc
anymore, but only the utility called c99
. Incidentally, my Linux system (Arch_Linux) contains a manpage of c99
but not c89
, but only contains a utility called cc
, but neither c89
nor c99
. Much confusion in there :)
Solution 3:
On my mac from man gcc
:
In Apple's version of GCC, both cc and gcc are actually symbolic links to a compiler named like gcc-version. Similarly, c++ and g++ are links to a compiler named like g++-version.
Based on that I would assume that cc and gcc behave the same way.