Fermi Physics Class Libraries Module: Compatibility Headers

ZOOM ZOOM

Compatibility Headers

Compatibility Headers Sub-package

This mini-package provides a set of header files, itemized below, designed to encapsulate certain environment-specific adaptations. By centralizing environment dependencies in this way, other ZOOM packages can be expressed via a single set of source files, without need for internal variants (typically #ifdef'd code). ZOOM packages freely use these headers as front ends to the environment-supplied headers, thereby ensuring a uniform interface. Users are encouraged to utilize these same header files where appropriate.

This package may be obtained from the following sources:


Description
User Interface
Internals
Example

Walter Brown, Module Coordinator
Fermilab Physics Class Library Task Force

Comments, questions about getting started, feature needs, and bug/annoyance reports may be sent to zoom-support@fnal.gov or zoom@fnal.gov.

Description

A part of the ZMutility package provides header files to ease coding in an environment in which not all compilers are fully standards-compliant. In particular, KCC (the KAI compiler) does support namespaces and the latest standard names for header files, while gcc (the GNU compiler) has no namespace support and provides only older header file names.

The intent is to provide a set of universal headers, each usable in either environment described above. These would be #include'd in user source code in lieu of their respective standard library equivalents.

We have encapsulated the necessary details among the following ZOOM headers:

our header replacement for
"ZMutility/algorithm"
<algorithm>
"ZMutility/cmath"
<cmath>
"ZMutility/ctime"
<ctime>
"ZMutility/iomanip"
<iomanip>
"ZMutility/iosfwd"
<iosfwd>
"ZMutility/iostream"
<iostream>
"ZMutility/fstream"
<fstream>
"ZMutility/sstream"
<sstream>
"ZMutility/map"
<map>

Note that our file names follow a predictable pattern: we use the standard name of the header we are encompassing/replacing, prefaced by the name of the containing package, ZMutility.

User Interface

To use these compatibility headers, the user simply #include's the desired file, per the above table, as illustrated below:

Internals

Each of these headers begins by (transparently) #include'ing "ZMutility/ZMenvironment.h" as a source of common #define's. The header then performs needed adaptations so as to make it appear that the appropriate standard header has been provided.

Additionally, if the environment supports namespaces, all identifiers from the std:: namespace are made globally available (via a using statement), so that a single style of user code will suffice for either environment.

If the environment does not support namespaces, the using keyword is disabled. This is done via the mechanism:

thus making the compiler subsequently ignore the line in non-namespace environments. Further, std is treated as a keyword in such contexts, and is ignored. This turns such constructs as std::string into ::string. The drawback is that std is no longer available for use as a valid (non-namespace) identifier.

Example

The following program, a development version of a test program for this package, exemplifies the use of some of the compatibility headers.

ZOOM Home Page - Fermilab at Work - Fermilab Home


Walter Brown
Last modified: May 22, 1998