2.1.2. Invoking the ARM compiler

Typically, the ARM compiler is invoked as follows:


armcc [options] ifile_1 ... ifile_n

You can specify one or more input files ifile_1 ... ifile_n. If you specify a dash - for an input file, the compiler reads from stdin. You can use the POSIX option -- to specify that all subsequent arguments are not treated as command switches. For example, to compile a file named -ifile_1 type:


armcc -O2 -- -ifile_1

Invoking the ARM compiler using older tool names

For backwards compatibility, you can still invoke the ARM compiler using one of the tool names supported in earlier compilation tools. The startup configuration associated with each of the older tool names is shown in Table 2.1.

Table 2.1. Start-up configuration based on old tool names 

Tool nameInstruction setSource language
armccARMC
tccThumbC
armcppARMC++
tcppThumbC++

Default behavior

Table 2.2 shows how the compiler start-up configuration is adjusted by the filename extension you specify.

Table 2.2. Start-up configuration as adjusted by filename extension 

Filename extensionInstruction setSource language
.cppNo adjustmentC++
.c++No adjustmentC++
.cpNo adjustmentC++
.cNo adjustmentNo adjustment
.tcThumbC
.tcppThumbC++
.acARMC
.acppARMC++

When you compile multiple files with a single command, all files must of the same type (either C or C++). The compiler cannot switch the language based on the file extension. The following example produces an error, because the compiler attempts to compile using the source language of test1.c:


armcc -c test1.c test2.cpp
Error: C3472E: No source language specified (--cpp or --c90) and sourcefile extensions conflict

If you specify files with conflicting file extensions you can force the compiler to compile either for C or for C++, regardless of file extension. For example:


armcc -c --cpp test1.c test2.cpp

See Setting the source language for details.

Support for processing PreCompiled Header (PCH) files is not available when you specify multiple source files in a single compilation. If you request PCH processing and specify more than one primary source file, the compiler issues an error message, and aborts the compilation. See Precompiled header files for details.

Overriding the default behavior

You can override the adjustments that the ARM compiler makes based on the filename extension (see Table 2.2) or the tool name you used to invoke the compiler (see Table 2.1). To do this, use the appropriate command-line option as shown in Table 2.3. See Pragmas controlling code generation for information on using pragmas to set source language.

Table 2.3. Start-up configuration as adjusted by overriding options 

Command-line optionInstruction setSource language

--c90

No adjustmentC

--cpp

No adjustmentC++

--arm

ARMNo adjustment

--thumb

ThumbNo adjustment

For example, if you submit the following command:


tcpp foo.acpp --c90

The compiler makes determinations as shown in Table 2.4.

Table 2.4. Example configuration 

Command ComponentDescriptionDefines instruction setDefines source language
tcppTool nameThumbC++
.acppFilename extensionARMC++

--c90

Command-line optionNo adjustmentC
 ResultARMC

The configuration that results from these considerations is shown in the Result row at the bottom of the table.

To summarize:

  • the filename extension overrides the default configuration determined by the tool name used to invoke the ARM compiler

  • the command-line option overrides the default configuration determined by the filename extension.

See Setting the source language and Targeting the instruction set for details on these options.

Copyright © 2005 ARM Limited. All rights reserved.ARM DUI 0282B
Non-Confidential