Next: Compiling and Linking with the Error Message Service
Up: EMS Error Message Service
Previous: Intercepting Messages
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 (emsAnnul
etc.) 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
for more details.)
Two additional functions are available for C programmers:
- emsErrno( char const *token, int errval )
This will assign the message associated
with a C errno (errval) to the specified token. Note that this is
logically different from emsSyser; on UNIX they produce the same
result but on other systems they may be different.
- emsSetnc( char const *token, char const *string, int maxchar )
This is similar to emsSetc but will limit the token length to
maxchar characters.
It must be used if string is not null-terminated.
ems.h defines ems_setc_c to be equivalent to
emsSetnc - there is no Fortran interface for this function.
A full list of the C function prototypes is provided in Appendix
.
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
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.
Next: Compiling and Linking with the Error Message Service
Up: EMS Error Message Service
Previous: Intercepting Messages
EMS Error Message Service
Starlink System Note 4
P C T Rees
A J Chipperfield
28 September 2001
E-mail:ussc@star.rl.ac.uk
Copyright © 2001 Council for the Central Laboratory of the Research
Councils