DateLib (TM) portability
The DateLib (TM) is a high portable library, but it seems that nothing can be 100% portable without any modifications.
To make the library as portable as possible the following decision have been made:
- C/C++ has been used as implementation language, because C is available on
nearly every platform - if you don't have a C compiler for a platform you can
mostly use the freely available GCC.
Another reason for using is that many other programming languages support an interface to C which allow it to use libraries as the DateLib is one.
- The datatypes used have been chosen carefully. For example it has been
avoided to use 'int', because it's size is not well defined - it could be of
16 bit size or of 32. So we use short for 16 bit values and long for 32 bit
values.
Additionally 'unsigned' has been used wherever possible as well as 'const'. The big problem with a boolean datatype is, that C++ now defines one, but C does not. This has been solved by using #define's.
- #define's are used to increase the portability. The following #define's can
be found within the system.h file:
#define Description bool should be defined as 'short' when not working under ISO-C++ true should be defined as '1' when not working under ISO-C++ false should be defined as '0' when not working under ISO-C++ VAR(n) this macro will be used within function definitions/prototypes. It defines a variable as a pointer type (C) or as reference (C++) VAL(n) This macro is used within a function body to access the value of a variable defined with VAR(n) ARG(n) This macro must be used for VAR(n) parameters when calling such a function. INLINE Allows the compiler to inline code - well defined for C++, but might be different for some C compilers. SNAME(n) This macro is a work-around for the SAS Institute C compiler 'enum' bug. Should be empty as long as you are not using the SAS compiler. The following #define's are used to create shared libraries - normally you should leave them untouched:
#define Description ALIGNED Align to next longword (4 byte) FAR Use far data reference STACKARGS Put function arguments onto the stack REGISTERARGS Put function arguments into registers ASM Required when using REG(r) or GCCREG(r) SAVEDS Make sure that the dataspace pointer is set SAVEDS_ASM Combination of SAVEDS and ASM DLL_EXPORT Export function for Microsoft Windows® DLL DLL_IMPORT Import function from Microsoft Windows® DLL D0-D7 680x0 data registers A0-A6 680x0 address registers REG(r) Register definition GCCREG(r) GCC register definition
#define Description INIT(modul,libbase) System dependent init code CLEAN(modul,libbase) System dependent cleanup code INITPROTO(modul,libbase) System dependent init code prototype CLEANPROTO(modul,libbase) System dependent cleanup code prototype INITCALL(modul,libbase) Used to call the system dependent init code CLEANCALL(modul,libbase) Used to call the system dependent cleanup code -
The following #define's are used for the optional debugging code - normally
you should leave them untouched:
#define Description DEBUG Debugging level DEBUG_PRINT_NEST Used for indention DEBUG_PCHECK(condition) Used for parameter checking DEBUG_ASSERT(condition) Assert condition within program code DEBUG_ENTER(function name) Enter function DEBUG_EXIT(function name, format template, return value) Exit function DEBUG_VARDUMP(variable name, format template, variable value) Dump variable DEBUG_POS Source code position -
The following #define's are used for optional code:
#define Description DATE_NO_HEIS Disable all "Heis" functions