2.4. Specifying Source Language and Specific Language Characteristics

The following command-line options specify the language standards the compiler should expect C/C++ source code to comply with and also what assumptions to make regarding particular data types.

armcl Option

tiarmclang Option

--c89 --c99

-std=<C standard identification>

The tiarmclang -std option can be used to instruct the compiler to process C files in accordance with the indicated ANSI/ISO C language standard. For the tiarmclang compiler, the available supported C option arguments are:

  • ‘c89’, ‘c90’, ‘iso9899:1990’ (ISO C 1990)

  • ‘iso9899:199409’ (ISO C 1990 with amendment 1)

  • ‘gnu89’, ‘gnu90’ (ISO C 1990 with GNU extensions)

  • ‘c99’, ‘iso9899:1999’ (ISO C 1999)

  • ‘gnu99’ (ISO C 1999 with GNU extensions)

  • ‘c11’, ‘iso9899:2011’ (ISO C 2011)

  • ‘gnu11’ (ISO C 2011 with GNU extensions)

If no -std option is specified when compiling a C source file, ‘gnu11’ is assumed by default.

By default, source files with a ‘.c’ extension are interpreted as C source files. The ‘-x c’ option can be specified on the command-line to force a source file that does not have a ‘.c’ extension to be interpreted as a C source file.

The tiarmclang compiler can handle a mix of C and C++ source files on a single invocation of the compiler. To interpret a file, regardless of its extension, as a C file, the ‘-x c’ option should be specified before that file on the tiarmclang command. All source files that follow the ‘-x c’ option will be interpreted as a C source file until another ‘-x’ option is encountered on the command-line.

armcl Option

tiarmclang Option

--c++03 --c++04

-std=<C++ standard identification>

The tiarmclang -std option can (also) be used to instruct the compiler to process C++ source files in accordance with the indicated ANSI/ISO C++ language standard. For the tiarmclang compiler, the available supported C++ option arguments are:

  • ‘c++98’, ‘c++03’ (IS0 C++ 1998 with amendments)

  • ‘gnu++98’, ‘gnu++03’ (ISO C++ 1998 with amendments and GNU extensions)

  • ‘c++11’ (ISO C++ 2011 with amendments)

  • ‘gnu++11’ (ISO 2011 with amendments and GNU extensions)

  • ‘c++14’ (ISO C++ 2014 with amendments)

  • ‘gnu++14’ (ISO C++ 2014 with amendments and GNU extensions)

  • ‘c++17’ (ISO C++ 2017 with amendments)

  • ‘gnu++17’ (ISA C++ 2017 with amendments and GNU extensions)

  • ‘c++2a’ (ISO C++ 2020 - working draft)

  • ‘gnu++2a’ (ISO C++ 2020 with GNU extensions - working draft)

If no -std option is specified when compiling a C++ source file, ‘gnu++17’ is assumed by default (beginning in version 3.1.0.STS).

By default, source files with a ‘.cpp’ extension are interpreted as C++ source files. The ‘-x c++’ option can be specified on the command-line to force a source file that does not have a ‘.cpp’ extension to be interpreted as a C++ source file.

The tiarmclang compiler can handle a mix of C and C++ source files on a single invocation of the compiler. To interpret a file, regardless of its extension, as a C++ file, the ‘-x c++’ option should be specified before that file on the tiarmclang command. All source files that follow the ‘-x c++’ option will be interpreted as a C++ source file until another ‘-x’ option is encountered on the command-line.

armcl Option (and alias)

tiarmclang Option

--cpp_default (-fg)

-x c++ --language=c++

The armcl compiler provides a --cpp_default option that tells the compiler to process all source files with a ‘.c’ extension as C++ source files.

The tiarmclang compiler’s ‘-x c++’ option provides similar support, but whereas armcl’s -fg option applies only to source files with ‘.c’ extensions, the tiarmclang compiler’s ‘-x c++’ option applies to any source file that is specified after the ‘-x c++’ option on the tiarmclang command-line up until another ‘-x’ option is encountered.

armcl Option

tiarmclang Option

-x <language type> --language=<language type>

The tiarmclang compiler’s -x or --language option provides a way to indicate how source files that are specified after the option are to be interpreted. There are four valid option arguments:

  • c++ - source files specified after the ‘-x c++’ option are interpreted as C++ source files

  • c - source files specified after the ‘-x c’ option are interpreted as C source files

  • assembler - source files specified after the ‘-x assembler’ option are interpreted as GNU-style Arm assembly language source files

  • ti-assembler - source files specified after the ‘-x ti-assembler’ option are interpreted as TI-style Arm assembly language source files

For example, suppose you have three source files, t1.cpp, t2.c, and t3.S. Assuming t2.c is C++ compatible and t3.S is a GNU-style Arm assembly language source file, one could then invoke the tiarmclang compiler with:

%> tiarmclang … t1.cpp -x c++ t2.c -x assembler t3.S … -o t.out …

to ensure that t2.c is interpreted as a C++ source file so that its object is compatible with t1.o, and also to interpret t3.S as a GNU-style Arm assembly language source file so that t3.o can be generated properly.

armcl Option

tiarmclang Option

--enum_type=<packed|unpacked|int>

-fshort-enums (default) -fno-short-enums

The armcl compiler assumes that enum type data objects are ‘packed’ by default. That is, the size of a given enum type is the number of bytes needed to represent the full range of values in that enum multiplied by the number of bits per byte.

Similarly, the tiarmclang compiler’s will also assume that enum type data objects are packed by default.

armcl Option

tiarmclang Option

--exceptions

-fexceptions

--extern_c_can_throw

on by default

By default, the tiarmclang compiler provides no C++ exception handling support. To enable exception handling, use the compiler’s -fexceptions option. See C++ Exception Handling for details.

Note

Support for C++ exceptions has now been added. Prior to version 3.1, C++ exceptions were not supported in tiarmclang.

By default, the tiarmclang compiler allows extern functions to propagate exceptions.

(The C library provides no built-in support for C exception handling. There is no equivalent to the --extern_c_can_throw option for C. See C Exception Handler Calling Convention.)

armcl Option (and alias)

tiarmclang Option

--gen_cross_reference_listing (-px)

not supported

The armcl compiler supports the -px option, which causes the compiler to emit a .crl file, which contains a listing of where symbols are referenced and defined.

The tiarmclang compiler does not support an analogous option.

armcl Option

tiarmclang Option

--gen_preprocessor_listing

not supported

The armcl compiler supports the --gen_preprocessor_listing option, which causes the compiler to emit a listing of the pre-processing output to an .rl file.

The tiarmclang compiler does not support an analogous option.

armcl Option (and alias)

tiarmclang Option

--plain_char=unsigned (default) --plain_char=signed (-mc)

-funsigned-char (default) -fsigned-char

Both the armcl and the tiarmclang compiler assume a “plain” char type is unsigned by default. Both compilers also support an option to interpret a “plain” char type as signed. For the armcl compiler, this option is --plain_char=signed, which maps to the tiarmclang’s -fsigned-char option.

armcl Option (and alias)

tiarmclang Option

--relaxed_ansi (-pr)

-std=gnu<90|99|11>

The armcl compiler supports GNU extensions to the C language if its -pr option is selected. To enable support of GNU extensions in the tiarmclang compiler, use one of the GNU settings (gnu90, gnu99, or gnu11) as the argument to tiarmclang’s -std option.

armcl Option

tiarmclang Option

--rtti

-fno-rtti (default) -frtti

By default, neither the armcl compiler nor the tiarmclang compiler allows C++ run-time type identification (RTTI). Use tiarmclang’s -frtti option, which is analogous to armcl’s --rtti option, to allow C++ RTTI.

armcl Option (and alias)

tiarmclang Option

--strict_ansi (-ps)

-std=c<90|99|11>

The armcl compiler provides the -ps option to allow you to disable support for GNU C extensions to the C standard. To disable support for GNU extensions in the tiarmclang compiler and approximate the behavior of armcl’s -ps option, use one of the non-GNU language settings (c90, c99, c11) as the argument to tiarmclang’s -std option.

All tiarmclang “-std=c<XX>” C language variants will define the __STRICT_ANSI__ predefined macro symbol.

You can combine “-std=c<XX>” with tiarmclang’s -pedantic option, which causes warnings to be issued for any conflicts with ISO C and ISO C++. The tiarmclang compiler’s -pedantic-errors option causes errors instead of warnings to be issued for such conflicts.

armcl Option

tiarmclang Option

--wchar_t=16 (default) --wchar_t=32

-fshort-wchar -fno-short-wchar (default)

The armcl compiler uses a default size of 16-bits for the wchar_t type, but the tiarmclang compiler uses a default size of 32-bits for the wchar_t type. Use -fshort-wchar to set the size of the wchar_t type to 16 bits.

If your application uses wchar_t type data objects and you are trying to interlink object files that were generated with the armcl compiler with object files that were generated by the tiarmclang compiler, then you might see errors generated at link-time to indicate that there is a disagreement in the compiler generated object files with regards to build attributes associated with the assumed wchar_t type size. You may need to recompile some source files with the desired wchar_t type size option in order to resolve these disagreements.