HP C Programmer's Guide (92434-90009)

Chapter 3 53
Calling Other Languages
Comparing HP C and HP Pascal
4. In non-ANSI mode, HP C promotes most float (32-bit) arguments to double (64-bit).
Therefore, all arithmetic using objects defined as float is actually using double code.
Float code is only used when the float objects are stored.
In ANSI mode where function prototypes have been declared with a float parameter,
no automatic promotion is performed. If the prototype is within the current scope,
floats will not be automatically promoted.
To call an HP Pascal routine that expects an argument of type REAL (32-bits), you may
either declare a function prototype in ANSI mode, use the +r command line option in
non-ANSI mode to always pass floats as floats, or declare the actual parameter as a
struct with a float as its only field, such as:
typedef struct {float f;} PASCAL_REAL_ARG;
5. HP Pascal global data can usually only be accessed by HP C if the data is declared at
the outermost level. HP Pascal stores the names of the objects in lowercase letters.
For example, the HP Pascal global:
PROGRAM example;
VAR
PASCAL_GLOBAL: INTEGER;
BEGIN END.
is accessed by HP C with this declaration:
extern int pascal_global;
The Pascal compiler directives $GLOBAL$ and $EXTERNAL$ can be used to share global data
between HP Pascal and HP C.
The $EXTERNAL$ directive should be used to reference C globals from a Pascal
subprogram
.
The $GLOBAL$ directive should be used to make Pascal globals visible to other languages
such as HP C. It should be used if it is necessary to share globals when calling C functions
from a Pascal
program
.
Linking HP Pascal Routines on HP-UX
When calling HP Pascal routines, you must include the HP Pascal run-time libraries by
adding the following option to the cc command line:
-lcl
Additionally, the -lm option may be necessary if the Pascal routines use the Pascal
predefined math functions.
For details on linking external libraries, see the -l option of the cc(1) and ld(1)
commands in the HP-UX Reference manual.