Node:How guile-snarf works, Next:Macros guile-snarf recognizes, Up:Init Snarfing with guile-snarf
Usage: guile-snarf [-o outfile] [cpp-args ...]
The
guile-snarf program will extract initialization actions to
outfile or to standard output when no outfile has been
specified or when outfile is
-.
If the environment variable
CPP is set, use its value instead of the
C pre-processor determined at Guile configure-time.
See Macros guile-snarf recognizes, for a list of the special (some would say magic) cpp macros you can use, including the list of deprecated macros.
For example, here is how you might define a new subr called
clear-image, implemented by the C function
clear_image:
#include <libguile.h> SCM_DEFINE (clear_image, "clear-image", 1, 0, 0, (SCM image_smob), "Clear the image.") #define FUNC_NAME s_clear_image { /* C code to clear the image in
image_smob... */ } #undef FUNC_NAME void init_image_type () { #include "image-type.x" }
The
SCM_DEFINE declaration says that the C function
clear_image implements a Scheme subr called
clear-image,
which takes one required argument (of type
SCM and named
image_smob), no optional arguments, and no rest argument.
See Doc Snarfing, for info on the docstring.
This works in concert with
FUNC_NAME to also define a static
array of characters named
s_clear_image, initialized to the
string "clear-image". The body of
clear_image may use the array
in error messages, instead of writing out the literal string; this may
save string space on some systems. (s_clear_image, 1, 0, 0, (SCM (*)() ) clear_image);
When compiled normally,
SCM_DEFINE is a macro which expands to
a declaration of the
s_clear_image string.