2.3.3. Setting the source language

This section describes options that determine the source language variant accepted by the compiler (see also Controlling code generation).

These options enable you to specify the compilation language used by the compiler, and to determine how strictly the compiler enforces the standards and conventions of that language. By default, the compiler compiles ISO C code. For C++ code, the compiler compiles as much as it can of ISO/IEC C++. For details on the default language assumed by the compiler, based on filename extension, see Invoking the ARM compiler.

The following options are used for setting the source language:

--cpp

Enables compilation of ISO/IEC C++. This is the default for *.cpp files.

--c90

Enables compilation of C rather than C++, specifically the C90 ISO version of C. This is the default for *.c files.

The default mode is a fairly strict ISO compiler, but without some of the inconvenient features of the ISO C Standard. Some minor extensions are also supported, for example // in comments and $ in identifiers.

--gnu

Enables or disables the GNU compiler extensions that are supported by the ARM compiler.

For details of the supported GNU extensions, see GNU extensions to the ARM compiler.

--no_strict

Relaxes the ISO language conformance. This is the default.

--strict --strict_warnings

Enables strict ISO mode (ISO/IEC 9899:1990 (E)) and the C++ Standard (ISO/IEC 14882:1998 (E)). Diagnostic messages are returned when nonstandard features are used, and features that conflict with ISO C or C++ are disabled. This is compatible in both C and C++ mode.

ISO violations can be issued as either warnings or errors, depending on the command-line option:

  • The --strict option causes errors to be issued.

  • The --strict_warnings option produces warnings.

The error threshold is set so that the requested diagnostics are returned (see Diagnostic messages).

For example, the following code segment returns an error when compiled with --cpp --strict, but only a warning with --cpp:


static struct T {int i; };

Because no object is declared, static is spurious. Therefore, in the C++ Standard, this code segment is invalid.

--anachronisms --no_anachronisms

Enables or disables anachronisms in C++ mode. This option is valid only in C++ mode. See Anachronisms for a complete description of anachronisms.

The default for this option is --no_anachronisms.

You can combine language options:

armcc --c90

Compiles ISO standard C, and the C mode of C++. This is the default.

armcc --strict

Compiles strict ISO standard C.

armcc --c90 --strict

Compiles strict ISO standard C (C mode of C++).

armcc --cpp

Compiles standard C++.

armcc --cpp --strict

Compiles strict C++.

armcc --c90 --gnu

Compiles ISO standard C, and the C mode of C++ with GNU extensions enabled (see GNU extensions to the ARM compiler).

armcc --cpp --gnu

Compiles standard C++ with GNU extensions enabled. By default, this disables exceptions handling (see GNU extensions to the ARM compiler).

Copyright © 2002-2005 ARM Limited. All rights reserved.ARM DUI 0205F
Non-Confidential