chickadee » feature-test » declare-foreign-features

(declare-foreign-features FEATURE1 FEATURE2 ...)syntax

For each feature F, tests whether F is #defined in C, and creates a new boolean #define reflecting this. This new #define is prefixed with the declaration-prefix.

For example, using the (default) declaration prefix HAVE_ and the feature AF_UNIX:

(declaration-prefix HAVE_)
(declare-foreign-features AF_UNIX)
/* generates the C code */
#ifdef AF_UNIX
#define HAVE_AF_UNIX 1
#define HAVE_AF_UNIX 0

The boolean define HAVE_AF_UNIX is now safely visible to a foreign-variable. In contrast, referring to AF_UNIX from Scheme when undefined would result in a compilation error.