It defines the following:
Common.h must be included by all source files either directly, or indirectly.
Common.h and Assertion draw on the work provided by the CoreLinux++ consortium [CORELINUX++].
Classes | |
struct | isEqual |
predicate for apgorithms to compare floating types like Volt, Time and Freq. | |
Defines | |
#define | DEBUG DFLAG_NONE |
define the subjects to include in debugging. | |
#define | DFLAG_NONE 0x0000 |
include no debug subjects. | |
#define | DFLAG_ALL 0xFFFF |
include all debug subjects. | |
#define | DFLAG_PRODUCTION (DFLAG_ALL & ~DFLAG_ENSURE) |
include all but ensure debug subjects. | |
#define | DFLAG_GENERAL 0x0001 |
debug subjects combined in one group. | |
#define | DFLAG_INTERFACE 0x0002 |
report more details on Rulbus Interface errors. | |
#define | DFLAG_BUSVIOLATION 0x0004 |
check for Rulbus address/data violations. | |
#define | DFLAG_REQUIRE 0x0010 |
design-by-contract: require pre-condition. | |
#define | DFLAG_ENSURE 0x0020 |
design-by-contract: ensure post-condition. | |
#define | DFLAG_NEVER_GET_HERE 0x0040 |
design-by-contract: ensure never reached. | |
#define | dim(a) (sizeof(a)/sizeof((a)[0])) |
array dimension. | |
#define | DECLARE_TYPE(mydecl, mytype) |
declare a new type and its pointer, const pointer, reference, and const reference types. | |
#define | DECLARE_CLASS(tag) |
declare class, class pointer, const pointer, class reference and const class reference types for classes. | |
#define | PROXY_CAST dynamic_cast |
use dynamic_cast to cast RulbusDevice to actual class type. | |
Typedefs | |
typedef isEqual< Volt > | Rulbus::isEqualVolt |
predicate to compare Volt | |
typedef isEqual< Time > | Rulbus::isEqualTime |
predicate to compare Time | |
typedef isEqual< Freq > | Rulbus::isEqualFreq |
predicate to compare Freq | |
typedef signed char | Rulbus::int8 |
the compiler's signed 8-bit integral type. | |
typedef unsigned char | Rulbus::uInt8 |
the compiler's unsigned 8-bit integral type. | |
typedef signed short int | Rulbus::int16 |
the compiler's signed 16-bit integral type. | |
typedef unsigned short int | Rulbus::uInt16 |
the compiler's unsigned 16-bit integral type. | |
typedef signed int | Rulbus::int32 |
the compiler's signed 32-bit integral type. | |
typedef unsigned int | Rulbus::uInt32 |
the compiler's unsigned 32-bit integral type. | |
typedef float | Rulbus::float32 |
the compiler's 32-bit real type. | |
typedef double | Rulbus::float64 |
the compiler's 64-bit real type. | |
typedef uInt8 | Rulbus::Byte |
the libraries' byte type. | |
typedef uInt16 | Rulbus::Word |
the libraries' word (2-Byte) type. | |
typedef uInt32 | Rulbus::Quad |
the libraries' double word (4-Byte) type. | |
typedef char | Rulbus::Char |
the libraries' character type. | |
typedef int | Rulbus::Int |
the libraries' signed integral type. | |
typedef int16 | Rulbus::Int16 |
the libraries' 16-bit signed integral type. | |
typedef int32 | Rulbus::Int32 |
the libraries' 32-bit signed integral type. | |
typedef double | Rulbus::Real |
the libraries' real type. | |
typedef float32 | Rulbus::Real32 |
the libraries' 32-bit real type. | |
typedef float64 | Rulbus::Real64 |
the libraries' 64-bit real type. | |
typedef std::string | Rulbus::String |
the libraries' string type. | |
typedef std::exception | Rulbus::StdException |
the std::exception type. | |
typedef String | Rulbus::Name |
the Rulbus device name type. | |
typedef Int | Rulbus::Addr |
the Rulbus address type. | |
typedef Int | Rulbus::Rack |
the Rulbus rack number type. | |
typedef Real | Rulbus::Volt |
the voltage type. | |
typedef Real32 | Rulbus::Volt32 |
the 32-bit voltage type. | |
typedef Real | Rulbus::Time |
the time type. | |
typedef Real | Rulbus::Freq |
the frequency type. |
|
DEBUG contains a bit-pattern that specifies which subjects must be included in the debugging:
Following Kernighan & Pike [1999], page 200, we use DEBUG in an
if ( DEBUG & DFLAG_BUSVIOLATION ) // action...
By using an If the (constant) condition evaluates to zero, the Borland C++ 5.6 compiler optimization process will change the test into an unconditional jump, so the debugging code incurs little execution overhead if not used. However the (unreachable) code for the if-statement is retained in the generated code. (Other compilers may remove the if-statement completely.)
/* * debug.cpp - determine presence of debugging code. */ #define DFLAG_NONE 0x0000 #define DFLAG_GENERAL 0x0001 #define DEBUG DFLAG_NONE void debug( const char *msg ); int main() { if ( DEBUG & DFLAG_GENERAL ) { debug( "general debugging" ); } return 0; } Generates the following assembly code:
.386p ifdef ??version if ??version GT 500H .mmx endif endif model flat ifndef ??version ?debug macro endm endif ?debug S "debug.cpp" ?debug T "debug.cpp" _TEXT segment dword public use32 'CODE' _TEXT ends _DATA segment dword public use32 'DATA' _DATA ends _BSS segment dword public use32 'BSS' _BSS ends DGROUP group _BSS,_DATA _TEXT segment dword public use32 'CODE' _main segment virtual @_main proc near ?live16385@0: ; ; int main() ; push ebp mov ebp,esp ; ; { ; if ( DEBUG & DFLAG_GENERAL ) ; @1: jmp short @2 ; ; { ; debug( "general debugging" ); ; push offset s@ call @@debug$qpxc pop ecx ; ; } ; ; return 0; ; @2: xor eax,eax ; ; } ; @4: @3: pop ebp ret @_main endp _main ends _TEXT ends _DATA segment dword public use32 'DATA' s@ label byte ; s@+0: db "general debugging",0 align 4 _DATA ends _TEXT segment dword public use32 'CODE' _TEXT ends @@debug$qpxc equ @debug$qpxc extrn @debug$qpxc:near ?debug D "debug.cpp" 12620 28747 end |
|
Value: class tag; \ typedef tag * tag ## Ptr; \ typedef const tag * tag ## Cptr; \ typedef tag & tag ## Ref; \ typedef const tag & tag ## Cref; |
|
Value: typedef mydecl mytype; \ typedef mytype * mytype ## Ptr; \ typedef const mytype * mytype ## Cptr; \ typedef mytype & mytype ## Ref; \ typedef const mytype & mytype ## Cref; |