2.1.2. Invoking the ARM compiler

Typically, the ARM compiler is invoked as follows:


armcc -c [optionsifile_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 treated as filenames, not as command switches.

For backwards compatibility, you can still invoke the ARM compiler using one of the tool names supported in earlier compilation tools. See Appendix E Using Older Options for details.

Default behavior

The compiler startup configuration (that is, C or C++, ARM or Thumb) is determined by the compiler from the:

  • tool name used to invoke the compiler

  • filename extension

  • command-line options --c90 or --cpp.

From these rules it follows that:

  • 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.

Table 2.1 shows how the compiler startup configuration is adjusted by the filename extension you specify.

Table 2.1. Startup configuration as adjusted by filename extension

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

When you compile multiple files with a single command, all files must be 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

Where an unrecognized extension begins with .c, for example, filename.cmd, a warning is given. See Setting the source language for full details on how the compiler determines the source language.

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.1) or the tool name you used to invoke the compiler. To do this, use the appropriate command-line option as shown in Table 2.2. See Pragmas controlling code generation for information on using pragmas to set source language.

Table 2.2. Startup 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.3.

Table 2.3. 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.

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

Copyright © 2002-2006 ARM Limited. All rights reserved.ARM DUI 0205G
Non-Confidential