C Checker Reference Manual

January 1998

next section previous section current document TenDRA home page document index


C.1 - Specifying integer literal types
C.2 - The Portability Table

C Integral Type Specification


C.1 Specifying integer literal types

The integer literal pragmas are used to define the method of computing the type of an integer literal. Integer literals cannot be used in a program unless the class to which they belong has been described using an integer literal pragma. Each built-in checking mode includes some integer literal pragmas describing the semantics appropriate for that mode. If these built-in modes are inappropriate, then the user must describe the semantics using the pragma below:

	#pragma integer literal literal_class lit_class_type_list
The literal_class identifies the type of literal integer involved. The possibilities are:

Each of these types can optionally be followed by unsigned and/or long to specify an unsigned and/or long type respectively.

The values of the integer literals of any particular class are divided into contiguous sub-ranges specified by the lit_class_type_list which takes the form below:

    lit_class_type_list
	*int_type_spec
	    integer_constant int_type_spec | lit_class_type_list
	int_type_spec :
	    : type_name
	    * warningopt : identifier
	    ** :
The first integer constant, i1 say, identifies the range [0,i1], the second, i2 say, identifies the range [i1+1,i2]. The symbol * specifies the unlimited range upwards from the last integer constant. Each integer constant must be strictly greater than its predecessor.

Associated with each sub-range is an int_type_spec which is either a type, a procedure token identifier with an optional warning (see G.9)or a failure. For each sub-range:

For example:

	#pragma integer literal decimal 0x7fff : int | 0x7fffffff : long | * : unsigned long
divides unsuffixed decimal literals into three ranges: literals in the range [0, 0x7fff] are of type int, integer literals in the range [0x7fff, 0x7fffffff] are of type long and the remainder are of type unsigned long.

There are four pre-defined procedure tokens supplied with the compiler which are used in the startup files to provide the default specification for integer literals:


C.2 The Portability Table

The portability table is used by the checker to describe the minimum assumptions about the representation of the integral types. It contains information on the minimum integer sizes and the minimum range of values that can be represented by each integer type.

Two built-in portability tables are provided. The default reflects the minimal requirements laid down in the ISO C standard. The 32-bit portability table (specified by the passing the -Y32bit option to tchk) reflects the implementation on most modern 32 bit machines. These tables are shown below.

ISO/ANSI Minimum Requirements Portability Table (default)

32 bit Portability table (specified by -Y32bit option)

The decimal integer associated with each of char_bits, short_bits , int_bits and long_bits gives the minimum number of bits in the representation of each integer type on all target machines. For example, if int_bits is set to 32 the compiler will perform its checks in the knowledge that the program will not be used on a machine whose int types are represented by 16 bits although they might be represented by 32 or 64 bits.

The minimum integer ranges are deduced from the minimum integer sizes as follows. Suppose b is the minimum number of bits that will be used to represent a certain integral type, then:


Part of the TenDRA Web.
Crown Copyright © 1998.