Precautions with compatible types, The shortreal type, Character strings – HP SunSoft Pascal 4.0 User Manual
Page 115
The C–Pascal Interface
91
6
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.
array
array
-
Same as element type
variant record
struct/union
-
-
fields in packed
record
bit field
-
-
Table 6-2
C 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
Table 6-1
C and Pascal Size and Alignment of Compatible Types (Continued)
Pascal Type
C Type
Size (bytes)
Alignment (bytes)