Standard implementation definition


This section discusses aspects of the ARM C compiler and ANSI C library not defined by the ANSI C standard, and which are implementation-defined.

Appendix A.6 of the ANSI C standard collects together information about portability issues; section A.6.3 lists those points which must be defined by each implementation. This section corresponds to appendix A.6.3, dealing with the points listed there, under the same headings and in the same order.

Translation

Diagnostic messages produced by the compiler are of the form:

"source-file", line-number: severity: explanation

where severity is one of:

Environment

The mapping of a command line from the ARM-based environment into arguments to main() is implementation-specific. The generic ARM C library supports the following:

In an unhosted implementation of the ARM C library, the term interactive device may be meaningless. The generic ARM C library supports a pair of devices, both called :tt, intended to handle a keyboard and a VDU screen. In the generic implementation:

Using the generic ARM C library, the standard input, output and error streams, stdin, stdout, and stderr can be redirected at run time in the way shown. For example, if mycopy is a program which simply copies the standard input to the standard output, the following line:

mycopy < infile > outfile 2> errfile

runs the program, redirecting stdin to the file infile, stdout to the file outfile, and stderr to the file errfile.

The following shows the allowed redirections:

--------------------------------------------------------
0< filename    |read stdin from filename                
--------------------------------------------------------
< filename     |read stdin from filename                
--------------------------------------------------------
               |                                        
--------------------------------------------------------
1> filename    |write stdout to filename                
--------------------------------------------------------
> filename     |write stdout to filename                
--------------------------------------------------------
               |                                        
--------------------------------------------------------
2> filename    |write stderr to filename                
--------------------------------------------------------
2>&1       |write stderr to same place as stdout    
--------------------------------------------------------
               |                                        
--------------------------------------------------------
>&         |write both stdout and stderr to filename
filename       |                                        
--------------------------------------------------------
>>          |append stdout to filename               
filename       |                                        
--------------------------------------------------------
>>&     |append both stdout and stderr to        
filename       |filename                                
--------------------------------------------------------

Identifiers

256 characters are significant in identifiers without external linkage. Allowed characters are letters, digits, and underscores.

256 characters are significant in identifiers with external linkage. Allowed characters are letters, digits, and underscores.

Case distinctions are significant in identifiers with external linkage.

In pcc mode (-pcc option) and "limited pcc" or "system programming" mode (-fc option), the character '$' is also valid in identifiers.

Characters

The characters in the source character set are assumed to be ISO 8859-1 (Latin-1 Alphabet), a superset of the ASCII character set. The printable characters are those in the range 32 to 126 and 160 to 255. Any printable character may appear in a string or character constant, and in a comment.

Other properties of the source character set are host specific, save that the ARM C compiler has no support for multi-byte character sets.

The properties of the execution character set are target specific. In its generic form, the ARM C library supports the ISO 8859-1 (Latin-1) character set, so the following points are expected to hold:

Integers

The representations and sets of values of the integral types are set out in Data Elements. Note also:

Floating point

The representations and ranges of values of the floating point types have been given in Data Elements. Note also that:

Arrays and pointers

The ANSI draft standard specifies three areas in which the behaviour of arrays and pointers must be documented. The points to note are:

Registers

Using the ARM C compiler, you can declare any number of objects to have the storage class register. Depending on which variant of the ARM Procedure Call Standard is in use, there are between five and seven registers available. Declaring more than this number of objects with register storage class must result in at least one of them not being held in a register. In general, it is advisable to declare no more than four. The valid types are:

Note that other variables, not declared with the register storage class, may be held in registers for extended periods, and that register variables may be held in memory for some periods.

Note also that there is a #pragma which assigns a file-scope variable to a specified register everywhere within a compilation unit.

Structures, unions, enumerations and bitfields

The ARM C compiler handles structures in the following way:

Qualifiers

An object that has volatile-qualified type is accessed if any word or byte of it is read or written. For volatile-qualified objects, reads and writes occur as directly implied by the source code, in the order implied by the source code.

The effect of accessing a volatile-qualified short is undefined.

Declarators

The number of declarators that may modify an arithmetic, structure or union type is limited only by available memory.

Statements

The number of case values in a switch statement is limited only by memory.

Preprocessing directives

A single-character constant in a preprocessor directive cannot have a negative value.

The ANSI standard header files are contained within the compiler itself and may be referred to in the way described in the standard (using, for example, #include <stdio.h>, etc.).

Quoted names for includable source files are supported. The rules for directory searching are given in Included files. The compiler will accept host file names or Unix file names. In the latter case, on non-Unix hosts, the compiler does its best to translate the file name to a local equivalent. See File naming conventions for more details.

The recognized #pragma directives and their meanings are described in Pragma directives.

The date and time of translation are always available, so __DATE__ and __TIME__ always give respectively the date and time.

Library functions

The precise attributes of a C library are specific to a particular implementation of it. The generic ARM C library has or supports the following features:

After the call setlocale(LC_CTYPE, "ISO8859-1"), the following statements also apply to character codes and affect the results returned by the ctype functions:

The mathematical functions return the following values on domain errors:

---------------------------------------------------------
Function   |Condition      |Return value                 
---------------------------------------------------------
log(x)     |x <= 0         |-HUGE_VAL                    
---------------------------------------------------------
log10(x)   |x <= 0         |-HUGE_VAL                    
---------------------------------------------------------
sqrt(x)    |x < 0          |-HUGE_VAL                    
---------------------------------------------------------
atan2(x,y) |x = y = 0      |-HUGE_VAL                    
---------------------------------------------------------
asin(x)    |abs(x) > 1     |-HUGE_VAL                    
---------------------------------------------------------
acos(x)    |abs(x) > 1     |-HUGE_VAL                    
---------------------------------------------------------

Where -HUGE_VAL is written above, a number is returned which is defined in the header math.h. Consult the errno variable for the error number.

The mathematical functions set errno to ERANGE on underflow range errors.

A domain error occurs if the second argument of fmod is zero, and HUGE_VAL is returned.

The set of signals for the generic signal() function is as follows:

--------------------------------------------------------
SIGABRT              |Abort                             
--------------------------------------------------------
SIGFPE               |Arithmetic exception              
--------------------------------------------------------
SIGILL               |Illegal instruction               
--------------------------------------------------------
SIGINT               |Attention request from user       
--------------------------------------------------------
SIGSEGV              |Bad memory access                 
--------------------------------------------------------
SIGTERM              |Termination request               
--------------------------------------------------------
SIGSTAK              |Stack overflow                    
--------------------------------------------------------

The default handling of all recognised signals is to print a diagnostic message and call exit. This default behaviour applies at program start-up.

When a signal occurs, if func points to a function, the equivalent of signal(sig, SIG_DFL) is first executed.

If the SIGILL signal is received by a handler specified to the signal function, the default handling is reset.

The generic ARM C library also has the following characteristics relating to I/O, (of course, any particular targeting of it may not have):

The following characteristics, required to be specified in an ANSI-compliant implementation, are unspecified in the generic ARM C library: