Programming Tools:prgtools

Constants defined by the compiler Foundation

By default, the Xbase++ compiler predefines some constants to identify the compiler and to identify the operating system. This allows program code specific for a compiler or an operating system to be excluded from compilation, using the directives #ifdef, #ifndef, #else and #endif. The #define constants are:

Predefined #define constants
#define Value Meaning Example
__XPP__ <version as string> Xbase++ compiler in use "Xbase++ (R) 1.80.277"
XPPVER <version as number> check for compiler versions 1800277
__WIN32__ Windows 32 bit version
__OS2__ OS/2 version of Xbase++
__XPP_PROFILE__ compiling with /profile

For example, if the same PRG file is to be compiled by Xbase++ and Clipper, there may be situations where both compilers behave differently. Such conflicts can be resolved as follows:

#ifdef __XPP__ 
    <Xbase++ Code> 
#else 
    <Clipper Code> 
#endif 

#ifdef XPPVER 
#if XPPVER > 01810000 
    <requires Xbase++ higher than version 1.8 to compile> 
#endif 
#endif 

In this way, program code for different compilers can be maintained in the very same PRG file.

Additional constants defined by the compiler are available for debugging and/or versioning purposes. They can be used in the following way:

? __FILE__, __LINE__, __DATE__, __TIME__ 

The compiler replaces these constants with the corresponding information, i.e. the values for these constants change while the compiler processes source code files.

__FILE__

A character string containing the name of the source code file.

__FILEPATH__

A character string containing the name and the complete path of the source code file.

__LINE__

A numeric value indicating the source line number where this constant appears.

__DATE__

A character string containing the compilation date in the format "YYYYMMDD", with YYYY being the year, DD is the day and MM is the month. This format can be converted to a variable of type Date by Stod().

__TIME__

A character string containing the compilation time in the format HH:MM:SS.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.