This chapter describes interfacing with ANSI C , X3.159-1989. See unnamedlink for a short overview of the C interface functionality. See unnamedlink for a introducion on built-in C types provided by the extended Sather library. In unnamedlink you find information about user defined external C types, constants, attributes, and shared elements. unnamedlink covers parameter passing issues, and finally unnamedlink describes the inline C facility.
An external class which interfaces to ANSI C is designated with the language identifier 'C'. Types defined by external C classes are called external C types. Similar to external Fortran types, signatures without bodies (abstract signatures) are allowed in external C types. Such signatures must contain only built-in or user defined C types and they are implemented externally in ANSI C. Abstract iterator signatures are not allowed in external C classes. Routines with bodies whose signatures contain only C types may be called from C. Routines with bodies whose signatures use types other than C types are regular Sather routines and are not accessible from C. External C routines cannot be overloaded.
In contrast with the external Fortran classes, external C classes may have attributes and objects of external C types may exist. All attributes must also be of C types. The C interface provides a naming facility that allows interoperability with the existing C header files.
Global C variables can be accessed as shared attributes of external C classes.
C symbols are generated by applying a platform specific C name binding convention to the textual external C routine names. It is also possible to explicitly specify name binding for external C classes.
Finally, it is possible to inline ANSI C code into Sather sources. This allows for even greater flexibility in achieving Sather/C interoperability.