This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

guile-snarf and C++


There are a couple of problems with guile-snarf using a C++ compiler
that I'm running into with SCWM (which still is a C program, but an
optional extension I'm working on uses a C++ class library).

First, the guile-snarf script assumes that `gcc' is the right way to
invoke the compiler.  If the code is to be compiled as C++, `g++' is the 
right way to invoke the compiler (and then, only if GNU's compiler suite 
is installed).  Since there are few differences between ANSI C's
preprocessor and C++'s, it might be possible to just pass -D__cplusplus
to guile-snarf when running guile-snarf from the makefile.

Second, I was looking at snarf.h from the June 30th snapshot and it
seems to be trying to do some really strange things with the
preprocessor:

<snip>
#ifndef SCM_MAGIC_SNARFER
#define SCM_PROC(RANAME, STR, REQ, OPT, VAR, CFN)  \
	static char RANAME[]=STR
#define SCM_PROC1(RANAME, STR, TYPE, CFN)  \
	static char RANAME[]=STR
#else
#ifdef __cplusplus
#if REQ == 0 && OPT == 0 && VAR == 0
#define SCM_PROC(RANAME, STR, REQ, OPT, VAR, CFN)  \
%%%	scm_make_gsubr (RANAME, REQ, OPT, VAR, (SCM (*) (void)) CFN)
<snip>

The intention appears to be to inspect the REQ, OPT, and VAR parameters
of expansions of SCM_PROC, and choose an appropriate cast for the
scm_make_gsubr call.  This obviously doesn't work, and instead the
definition shown is the only one ever used.

The fix is to defer that processing until the processing that happens
after the pipe in guile-snarf.  Of course, that processing will get a
little more complex, but it's still pretty straightforward.

Greg J. Badros
gjb@cs.washington.edu
Seattle, WA  USA
http://www.cs.washington.edu/homes/gjb