Next: , Up: glibc   [Index]


5.1 Feature–based expansion

Syntax: cond-expand (?feature-requirement ?body0 ?body …) …

Process the given clauses in left–to–right order and expand to the sequence of ?body forms from the first clause for which the ?feature-requirement is satisfied.

This syntax supports all the features defined by cond-expand from SRFI-0 (see Features supported by Vicare), and in addition it supports a feature for each system function exported by (vicare glibc); such features use the identifier exported by the library as feature requirement.

As example, some platforms implement fdatasync while others only have fsync, to select among them we write the following:

(import (vicare)
  (prefix (vicare glibc) glibc.))

(glibc.cond-expand
  (glibc.fdatasync
   (do-something))
  (glibc.fsync
   (do-something-else))
  (else
   (raise-error)))