| |||
| Home > Creating an application > Using the compiler | |||
The compiler, armcc, can compile C and C++ source code into ARM and Thumb code.
Typically, you invoke the compiler as follows:
armcc [options] ifile_1 ... ifile_n
You can specify one or more input files.
To compile the C++ example source file shapes.cpp:
Compile the C++ file shapes.cpp with
the following command:
armcc --cpp --debug -c -O1 shapes.cpp -o shapes.o
The following options are commonly used:
-cTells the compiler to compile only, and not link.
-cppTells the compiler that the source is C++.
--debugTells the compiler to add debug tables for source-level debugging.
-O1Tells the compiler to generate code with restricted optimizations applied to give a satisfactory debug view with good code density and performance.
-o filenameTells the compiler to create an object file with
the specified .filename
Be aware that --arm is the default compiler
option.
Link the file:
armlink shapes.o --info totals -o shapes.axf
Use an ELF, DWARF 2, and DWARF 3 compatible debugger to load and run the image.
See the readme.txt file that accompanies
the example for more information.
The following compiler options generate ARM code:
--armTells
the compiler to generate ARM code in preference to Thumb code. However, #pragma
thumb overrides this option.
This is the default compiler option.
--arm_onlyForces
the compiler to generate only ARM code. The compiler behaves as
if Thumb is absent from the target architecture. Any #pragma
thumb declarations are ignored.
To build a Thumb version use:
armcc --thumb ...
where:
--thumbTells the compiler to generate Thumb code in preference
to ARM code. However, #pragma arm overrides this
option.