4.1.4 C99 language function

This section describes the C99 language functions supported by the CC-RL.

(1)

Comment by //

Text from two slashes (//) until a newline character is a comment. If there is a backslash character (\) immediately before the newline, then the next line is treated as a continuation of the current comment.

(2)

Concatenating wide string literal

The result of concatenating a character string literal with a wide string literal is a wide string literal.

(3)

_Bool type

_Bool type is supported.

_Bool type is a 1-byte integer type that holds only 0 or 1.

When the -ansi option is specified, _Bool type is not supported and it generates a compilation error.

(4)

long long int type

long long int type is supported. long long int type is an 8-byte integer type.

Appending "LL" and "ULL" to a constant value is also supported. It is also possible to specify this for bit field types.

When the -ansi option is specified, the long long int type is not supported and it generates a compilation error.

(5)

Integer promotion

In accordance with support for types _Bool and long long, integer promotion is also in accordance with the C99 specification.

When the -ansi option is specified, _Bool type and long long type is not supported and integer promotion is in accordance with the C90 specification.

(6)

Aggregate initialization

The initializer for an aggregate or union type object that has automatic storage duration conforms to the C99 specifications.

In the C90 specifications, only a constant expression is allowed for an initializer, but other expressions can be used in CC-RL.

void func(int param) {
        int i = param;              //Allowed both in C90 and C99
        int array[] = { param };    //Not allowed in C90, allowed in C99, and 
                                    //allowed in CC-RL

(7)

Default argument promotions

In accordance with support for types _Bool and long long, default argument promotions is also in accordance with the C99 specification..

-

Functions are called after expanding type _Bool_ to type int (2 bytes).

-

Functions are called with type (unsigned) long long remaining as an 8 bytes value.

-

When the option -dbl_size=4 is used, functions are called with type float remaining 4 bytes.
This is because as a result of this option, even if a float is promoted to a double, the double type will have 4 bytes (same as the float type).

 

A near pointer is converted to a far pointer.

void* conforms to the rules for variable pointers.

(8)

Comma permission behind the last enumerator of a enum definition

When defining an enum type, it is permissible for the last enumerator in the enumeration to be followed by a comma (,).

enum EE {a, b, c,};

 

When the -ansi option is specified, this comma will generate an error.

(9)

Types of integer constants

In accordance with the addition of type long long, the types of integer constants are as follows.

The type of an integer constant will be the first type in the lists below capable of representing that value.

Table 4.6

Types of Integer Constants (If type long long is enabled (when -ansi is not specified))

Suffix

Decimal Constant

Binary Constant, Octal Constant, or Hexadecimal Constant

None

int

long int

unsigned long intNote

long long int

unsigned long long int

int

unsigned int

long int

unsigned long int

long long int

unsigned long long int

u or U

unsigned int

unsigned long int

unsigned long long int

unsigned int

unsigned long int

unsigned long long int

l or L

long int

unsigned long intNote

long long int

long int

unsigned long int

long long int

unsigned long long int

Both u or U, and l or L

unsigned long int

unsigned long long int

unsigned long int

unsigned long long int

ll or LL

long long int

long long int

unsigned long long int

Both u or U, and ll or LL

unsigned long long int

unsigned long long int

Note

Different from C99 specification. This is added to avoid the case where an integer constant represented as 4-byte data in C90 is unexpectedly represented as 8-byte data.

Table 4.7

Types of Integer Constants (If type long long is disabled (when -ansi is specified))

Suffix

Decimal Constant

Binary Constant, Octal Constant, or Hexadecimal Constant

None

int

long int

unsigned long int

int

unsigned int

long int

unsigned long int

u or U

unsigned int

unsigned long int

unsigned int

unsigned long int

l or L

long int

long int

unsigned long int

Both u or U, and l or L

unsigned long int

unsigned long int

(10)

Addition of standard header

Standard header stdint.h is added, which defines the following types.

Table 4.8

Type Definition Names in stdint.h

Type Name

Actual Type

Remark

int8_t

signed char

 

int16_t

signed short

 

int32_t

signed long

 

int64_t

signed long long

When -ansi is not used

uint8_t

unsigned char

 

uint16_t

unsigned short

 

uint32_t

unsigned long

 

uint64_t

unsigned long long

When -ansi is not used

int_least8_t

signed char

 

int_least16_t

signed short

 

int_least32_t

signed long

 

int_least64_t

signed long long

When -ansi is not used

uint_least8_t

unsigned char

 

uint_least16_t

unsigned short

 

uint_least32_t

unsigned long

 

uint_least64_t

unsigned long long

When -ansi is not used

int_fast8_t

signed char

 

int_fast16_t

signed short

 

int_fast32_t

signed long

 

int_fast64_t

signed long long

When -ansi is not used

uint_fast8_t

unsigned char

 

uint_fast16_t

unsigned short

 

uint_fast32_t

unsigned long

 

uint_fast64_t

unsigned long long

When -ansi is not used

intptr_t

signed long

 

uintptr_t

unsigned long

 

intmax_t

signed long

When -ansi is used

signed long long

When -ansi is not used

uintmax_t

unsigned long

When -ansi is used

unsigned long long

When -ansi is not used

 

stdint.h defines the following macros.

Table 4.9

Macro Definition Names in stdint.h

Macro Name

Value

Remark

INT8_MIN

-128

 

INT16_MIN

-32768

 

INT32_MIN

-2147483648

 

INT64_MIN

-9223372036854775808

When -ansi is not used

INT8_MAX

+127

 

INT16_MAX

+32767

 

INT32_MAX

+2147483647

 

INT64_MAX

+9223372036854775807

When -ansi is not used

UINT8_MAX

+255

 

UINT16_MAX

+65535

 

UINT32_MAX

+4294967295

 

UINT64_MAX

+18446744073709551615

When -ansi is not used

INT_LEAST8_MIN

-128

 

INT_LEAST16_MIN

-32768

 

INT_LEAST32_MIN

-2147483648

 

INT_LEAST64_MIN

-9223372036854775808

When -ansi is not used

INT_LEAST8_MAX

+127

 

INT_LEAST16_MAX

+32767

 

INT_LEAST32_MAX

+2147483647

 

INT_LEAST64_MAX

+9223372036854775807

When -ansi is not used

UINT_LEAST8_MAX

+255

 

UINT_LEAST16_MAX

+65535

 

UINT_LEAST32_MAX

+4294967295

 

UINT_LEAST64_MAX

+18446744073709551615

When -ansi is not used

INT_FAST8_MIN

-128

 

INT_FAST16_MIN

-32768

 

INT_FAST32_MIN

-2147483648

 

INT_FAST64_MIN

-9223372036854775808

When -ansi is not used

INT_FAST8_MAX

+127

 

INT_FAST16_MAX

+32767

 

INT_FAST32_MAX

+2147483647

 

INT_FAST64_MAX

+9223372036854775807

When -ansi is not used

UINT_FAST8_MAX

+255

 

UINT_FAST16_MAX

+65535

 

UINT_FAST32_MAX

+4294967295

 

UINT_FAST64_MAX

+18446744073709551615

When -ansi is not used

INTPTR_MIN

-2147483648

 

INTPTR_MAX

+2147483647

 

UINTPTR_MAX

+4294967295

 

INTMAX_MIN

-2147483648

When -ansi is used

-9223372036854775808

When -ansi is not used

INTMAX_MAX

+2147483647

When -ansi is used

+9223372036854775807

When -ansi is not used

UINTMAX_MAX

+4294967295

When -ansi is used

+18446744073709551615

When -ansi is not used

PTRDIFF_MIN

-32768

 

PTRDIFF_MAX

+32767

 

SIZE_MAX

+65535

 

(11)

Variadic macro

The variadic macro is enabled.

#define pf(form, ...) printf(form, __VA_ARGS__)
 
pf("%s %d\n", "string", 100);
             
printf("%s %d\n", "string", 100);