6.4.1 Data Type Compatibility

You should follow normal C programming conventions for writing portable programs. You should already be aware of the dangers of mixing integers and pointers indiscriminately and expecting the program to work on other machines. However, we have one warning appropriate for C programs using C/Base: the int data type may be a different size on the destination machine.

This is especially critical in C structures that are used for reading and writing RMS data records. Integer fields in RMS records may be either 2 or 4 bytes. The number of bytes in a RMS integer is machine dependent and is the "natural" size of an integer (this is defined by the C compiler). This is the default size assigned when a RMS integer is defined in C/Base. However, once the number of bytes in a RMS field is defined, it is not changed when the file definition is moved to a computer where the "natural" size of an integer is different. Thus, the integer in the C structure must be declared properly so its size will not change if moved to another machine.

An integer variable in a C program corresponding to an integer field in a RMS record should be declared in the C record structure either as short int (if the RMS integer is two bytes) or long int (if the RMS integer is four bytes), not just plain int. As long as short int or long int is used in the structure declaration, the variable remains the same size on the destination machine. The default size of an int will not matter.