8 C Language Interface

To enable EMS to be used in C-only programs, without the need to link with Fortran libraries, it has now been implemented entirely in C. A C function equivalent exists for each of the Fortran EMS routines described in this document except EMS_FIOER which is specific to the Fortran language and has therefore been omitted.

The current naming scheme for the C functions (emsAnnuletc.) replaces the earlier one (ems_annul_c etc.), but the old names will still be recognised. There is no change to the argument lists. (See Appendix G for more details.)

Additional functions are available for C programmers:

A full list of the C function prototypes is provided in Appendix G.

The function emsExpnd has the argument maxlen, not found in its equivalent Fortran call sequence. This argument represents the maximum allowable string length for the expanded message and is necessary for the use of returned C character strings where the declared length cannot be determined. Normally, the argument maxlen is given the global constant value EMS__SZMSG. There should be space for maxlen+1 characters in the output string.

The correspondence between ANSI Fortran 77 data types and ANSI C data types is not defined: i.e. it is implementation dependent. However, the most likely correspondence can be assumed and this has been coded into the C/Fortran interface. This correspondence is apparent from the C interface function prologues provided in Appendix G and is summarised in the following table:



C Type Fortran Type


double DOUBLE PRECISION
float REAL
int INTEGER
int LOGICAL
char CHARACTER


Note that the interpretation of the int lvalue argument presented to the function emsSetl is that defined by the ANSI C language.