15.12 Programming for Multiple X Releases

In R5 and later, Xlib defines the symbol XlibSpecificationRelease with the release number as the value (i.e., 5). This can be used to allow an application to successfully compile with more than one release of Xlib (assuming of course it depends only on features present in the releases which it will be compiled). Example 15-4 shows a code segment into which R4, R5 and R6 code could be inserted:

Example 15-4. Using the XlibSpecificationRelease symbol

#ifdef XlibSpecificationRelease
    if (XlibSpecificationRelease == 5)
        ;/* R5 */
    else if (XlibSpecificationRelease == 6)
        ;/* R6 */
    else
        ;/* R7 or error */
#elseif
    /* R4 */
#endif

Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.