What is xContract?
Version 0.3.3
xContract is a contract enforcement library for C and C++, written in C. Its notable features are:
- Phase Separation. It supports the separation of the three phases of contract enforcement: detection, reporting and response. Detection is achieved by simple boolean condition evaluation. Reporting is achieved via a callback function, either the stock xContract_violationReport() function, or one supplied by the user. Response is to terminate the process.
- The Principle of Irrecoverability. If the reporting receiver does not cause the process to terminate, then the library will always do so.
- The Principle of Removability. Enforcements may be enabled/disabled either at compile-time or at runtime according to the choices of the programmer
- Portability. It relies on no platform-specific or compiler-specific constructs. The only library it relies on is the 100% header-only, open-source STLSoft library. It works with a large number of C/C++ compilers.
xContract is the second of a triumvirate of C/C++ software quality assurance libraries provided by Synesis Software. The first library, xTests, is an automated testing library. The third, as yet unreleased, library, xCover, is an automated code coverage library.
xContract is written in C, and presents a simple C API, that may be used from C and C++.
A future version may provide a C++ API with additional facilities
xContract is released under the
BSD license, which basically means its free for any use, but you can't claim it's yours.
xContract works on with
many compilers, is
platform independent, and requires only
one other library.
xContract itself is a platform-independent library. It has been tested and used on both UNIX and Windows - in principle, it should work on any operating system for which a (reasonably modern) C/C++ compiler exists.
xContract is written in standard C/C++, and should be compilable with any modern C/C++ compiler that provides an implementation of the C & C++ standard libraries.
xContract has been built and tested with the following compilers:
- Borland C/C++ 5.5.1
- Borland C/C++ 5.6
- Borland C/C++ 5.6.4
- Borland C/C++ 5.82
- Metrowerks CodeWarrior 8+
- Comeau C++ 4.3.3
- Digital Mars 8.50+
- GNU C/C++ 3.4+
- Intel C/C++ 6.0+
- Visual C++ 6.0+
If you wish to use xContract with a compiler not listed here, you may find the STLSoft header file will issue a #error informing you that your chosen compiler is not supported. This can be overriden by defining the pre-processor symbol _STLSOFT_FORCE_ANY_COMPILER. If you do that, your compiler will be expected to be pretty standards compliant (though nothing that's particularly out-of-this-world, such as export). If you run into any issues with using xContract/STLSoft with such a compiler, we'd be happy to hear from you on the STLSoft newsgroup.
xContract is dependent on the STLSoft libraries, version
1.9.55, or later.
STLSoft provides the following important features:
- Compiler feature discrimination, standard library feature discrimination, various STL extension algorithms and iterator adaptors.
- Efficient memory management components.
- Extended limits classes and meta-programming components.
- Extended string manipulation functions.
Because STLSoft is 100% header-only, there is no need to build anything in order to use STLSoft with xContract. Simply define the STLSOFT environment variable, as described in the STLSoft distribution.
xContract is written by
Matthew Wilson, author of the books
Imperfect C++ and
Extended STL, volume 1, and the
STLSoft,
Pantheios, and
FastFormat libraries.