Using constants with ARC.EXE Foundation
Instead of numeric IDs, #define constants can be used in an ARC file just as in a PRG file. This has the obvious advantage that resources can be identified in both ARC and PRG files using the same constants. To accomplish this, the constants are defined in a CH file. The resource compiler understands the directives #inlude, #define, #ifdef, #ifndef, #elseand #endif, and treats them in the same way as the Xbase++ compiler. Therefore, it is possible to declare resources in the following way:
This example shows the code for a CH file which defines constants for the numeric resource IDs. The constants are used in the ARC file since ARC.EXE can resolve the #include directive.
Only bitmap resources are declared in the example. The keyword BITMAP is written in a separate line and is followed by a block of resource declarations of the same type. ARC supports this syntactical form for declaring resources which results in better readability of the ARC file. If a keyword is written on a line by itself, all following lines declare the same resource type without repeating the keyword.
The last lines in the example demonstrate how operating system-specific resources can be declared in one and the same ARC file. The directives #ifdef, #else and #endif are used, thus allowing for a conditional compilation. ARC.EXE uses the same implicit #define constants as the Xbase++ compiler: __OS2__ and __WIN32__.
Additionally, the resource compiler predefines a constant to identify the compiler. The #define is:
#define | Meaning |
---|---|
__ARC__ | Xbase++ resource compiler in use |
For example, if the same CH file is to be included from a PRG source file and from an ARC resource file then resource compiler specific directives can be hidden from the Xbase++ compiler as follows:
Header file "header.ch":
In this way resource IDs and their associated source files can be maintained in the very same header file even so they are compiled by the Xbase++ compiler and the resource compiler.
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.