C++ User's Guide

Diagnosing the Compiler

You can use the -verbose option to display helpful information while compiling a program. See Chapter 3, C++ Compiler Options for more information.

Any arguments on the command line that the compiler does not recognize are interpreted as linker options, object program file names, or library names.

The basic distinctions are:

In the following example, note that -bit is not recognized by CC and the option is passed on to the linker (ld), which tries to interpret it. Because single letter ld options can be strung together, the linker sees -bit as -b -i -t, all of which are legitimate ld options. This might not be what you intend or expect:


demo% CC -bit move.cc           <- 
 -bit is not a recognized 
CC option

CC: Warning: Option -bit passed to ld, if ld is invoked, ignored otherwise

In the next example, the user intended to type the CC option -fast but omitted the leading dash. The compiler again passes the argument to the linker, which in turn interprets it as a file name:


demo% CC fast move.cc           <-   The user meant to type 
-fast
move.C:
ld: fatal: file fast: cannot open file; errno=2
ld: fatal: File processing errors.  No output written to a.out