TOC PREV NEXT INDEX DOC LIST MASTER INDEX



Standard C Library

The implementation of the Standard C library is dependent on the type of Apex system: native, cross for Rational Exec or cross for Tornado/Lynx. These are discussed in this chapter.


Native Systems

Apex C assumes that a C compiler already exists on the system. Among other things, it needs to borrow header files and libraries from the host compiler. Apex C uses the host system's header files and libraries as much as possible. There are a few header files which deal with the internals of the compiler rather than the library (such as stdarg.h, varargs.h, and float.h) that are replaced, but most of them are used without modification. Therefore, programs should behave almost exactly the same whether they are compiled by the host compiler or by Apex C. The user should consult the documentation for the host system for the behavior of the libraries.

On Sun systems, there is one significant difference between the host compiler and Apex C that may cause problems. Apex C does not support the 80-bit IEEE floating-point format; the double and long double types are identical and both are 64 bits long. Sun C compilers use the 80-bit format for the long double type. This causes problems with the printf and scanf families of functions. For example, given the code

The library is expecting the second argument to be an 80-bit floating-point value, while Apex C is only passing it a 64-bit value. Because the calling conventions for the two types are completely different, this will most likely result in a segmentation violation. scanf and relatives have the same problem, though the exact behavior is harder to predict. This will be a problem any time a function with a long double argument or long double return type is compiled with one compiler and called by code compiled with the other compiler.


Cross for Rational Exec Systems

Apex C comes with a relatively complete implementation of the standard C library. There are very few extensions, the biggest one being the macros in varargs.h. In general, only those functions, macros, types, and variables defined by the ISO/ANSI C standard are available.

Several functions are not implemented due to lack of operating system support: getenv, rename, and system. rename always returns -1. getenv always returns a NULL pointer.


Cross for Tornado and LynxOS Systems

Apex C provides the C/C++ compiler, but uses header files and libraries provided by the target OS vendor. These libraries provide a nearly complete implementation of the standard C library, as well as providing many extensions that are common for UNIX systems.

Vendor supplied headers and libraries are resolved through the APEX_WIND_BASE (Tornado) or APEX_LYNX_ROOT (LynxOS) session switches which are defined at installation.


Rational Software Corporation 
http://www.rational.com
support@rational.com
techpubs@rational.com
Copyright © 1993-2002, Rational Software Corporation. All rights reserved.
TOC PREV NEXT INDEX DOC LIST MASTER INDEX TECHNOTES APEX TIPS