Previous: Macros c2x recognizes, Up: Init Snarfing
The SCM_DEFINE macro essentially provides three stylized pieces of
information to the C compiler: (1) a C function declaration, visible during
normal compilation; and (2) a C-code fragment that connects the C function to
the Scheme environment and (3) function documentation (including function
argument count and names), both (2) and (3) visible during processing by
c2x. These are handled by the C macros SCM_SNARF_HERE,
SCM_SNARF_INIT, and SCM_SNARF_DOCS, respectively.
By default the C macro SCM_DEFINE declares its procedure globally,
which may not be what you need exactly. The following fragment shows how to
create a macro PROJ_DEFINE that mostly behaves like SCM_DEFINE
with the exception that the procedure is declared static:
/* SCM_DEFINE alone doesn't declare static, so we prefix that decl. */
#define PROJ_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \
SCM_SNARF_HERE(static SCM FNAME ARGLIST;) \
SCM_DEFINE (FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING)
Note that PROJ_DEFINE uses two other macros to actually do job,
in this case prefixing the SCM_DEFINE with SCM_SNARF_HERE.