6

Table 6-1C and Pascal Size and Alignment of Compatible Types (Continued)

Pascal Type

C Type

Size (bytes)

Alignment (bytes)

 

 

 

 

array

array

-

Same as element type

 

 

 

 

variant record

struct/union

-

-

 

 

 

 

fields in packed

bit field

-

-

record

 

 

 

 

 

 

 

Table 6-2C and Pascal Size and Alignment of Compatible Types with –xl

 

 

 

 

Pascal Type

C Type

Size (bytes)

Alignment (bytes)

 

 

 

 

real

float

4

4

 

 

 

 

integer

short int

2

2

 

 

 

 

Precautions with Compatible Types

This section describes the precautions you should take when working with compatible types.

The shortreal Type

The Pascal shortreal and C float compatibility works if you pass by reference. See “Value Parameters” on page 112 for examples that show you how to pass by value.

Character Strings

C has several assumptions about strings. All C strings are:

Passed by reference since C strings are arrays

Terminated by a null byte

Located in static variable storage

You can satisfy these assumptions as follows:

Pass by reference by making the strings var, in, out, or in out parameters.

Provide the null byte explicitly before passing a string to C. Pascal guarantees the null byte only if the string is a constant. The null byte is not required by the ISO Pascal Standard.

The C–Pascal Interface

91