Up | Previous | Next | Title Page | Contents

2.3 C Calling Sequence

All RTL routines have a C language binding: every routine has an entry point that uses C-style arguments and calling sequences. All portable C language programs use the C language interface to the RTL.
The C-language routines are named similarly to the old (now FORTRAN-style) routines, but start with a “ z” instead of “ x”. For example, instead of calling xvwrit or xlget, a C program would now call zvwrit or zlget.

2.3.1 C Data Types

The standard C definitions for each of the VICAR pixel data types are listed. See Table 4: C Declarations for Pixel Types. The data types that may be passed into the RTL, and the C declarations for each type, are listed in Table 6: C Declarations for Run-Time Library Arguments.(below)
Pixel Type
C Declaration
BYTE
unsigned char
HALF
short int
FULL
int
REAL
float
DOUB
double
COMP
struct complex {float r, i; \};

Table 4: C Declarations for Pixel Types

RTL Argument Type
C Declaration
integer
int
string
char x[n]
value
int, char x[n], float, or double
integer array
int x[m]
string array
char x[m][n]
value array
array of any “ value” type above
pixel buffer
pointer to any pixel type. See Table 4: C Declarations for Pixel Types
FORTRAN string
char *x
FORTRAN string array
char *x
void pointer
void *x (actually, a pointer to anything)
pixel pointer
address of pointer to any pixel type. See Table 4: C Declarations for Pixel Types
pointer to string array
char **x

Table 6: C Declarations for Run-Time Library Arguments

Because labels and parameters can have more than one value, the routines that deal with them must be able to accept (or output) arrays of strings. The RTL expects all arrays of strings to be two-dimensional arrays of “char”. This does not mean an array of pointers to strings, but a pointer to an area of memory n*m bytes long, where n is the maximum size of each string and m is the number of strings. The inner dimension, n, must be passed in to the routine so it knows how to access the string array.
All RTL routines that use string arrays have a way to specify the length. The length is the size of the inner dimension; it is not the length of any particular string, but must include space for the null terminator at the end of a string. For example, if a string has at most 10 characters, make sure the length is at least 11 to allow room for the null terminator.

Up | Previous | Next | Title Page | Contents