2.7 Compatible and Composite Types

Compatibility between types refers to the similarity of two types to each other. Type compatibility is important during type conversions and operations. All valid declarations in the same scope that refer to the same object or function must have compatible types. Two types are compatible if they fit any of the following categories:

The following types, which may appear to be compatible, are not:

Composite Type

A composite type is constructed from two compatible types and is compatible with both of the two types. Composite types satisfy the following conditions:

Consider the following file-scope declarations:

int f(int (*) (), double (*) [3]);
int f(int (*) (char *), double (*)[]);

They result in the following composite type for the function:

int f(int (*) (char *), double (*)[3]);

The previous composite type rules apply recursively to types derived from composite types.


Previous Page | Next Page | Table of Contents | Index