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]

Re: C++, guile-snarf, and guile-1.3



> I had to put a hack into guile-snarf in order to use guile-1.3 with
> the Sparcworks C++ compiler.
> 
> Here is my hacked version, which relaxes the assumption that gcc is
> being used, and that also adds a type cast to the last argument of
> scm_make_gsubr to stop the C++ compiler from complaining.  I guess
> this would be better done in the preprocessor macro, rather than with
> sed (the sed clause I have added is a bit frightening).
> 
> It is not generally safe to assume that since gcc was used to build
> guile, that only gcc will be used when building programs that use guile,
> so I think that explicitly forcing gcc in guile-snarf is a bug.

Actually, there is something more subtle going on here.  Guile doesn't
assume that you're using GCC.  The configure script runs some tests to
figure out how to invoke the C preprocessor, and produces guile-snarf
from guile-snarf.in.  guile-snarf.in doesn't specify a compiler; it
just says @CPP@, which autoconf could replace with `cc -E', `gcc -E',
or `/lib/cpp'.

What you're saying is, guile-snarf should allow the user to specify
the C preprocessor to use.

Please give the following patch a try:



1998-10-24  Jim Blandy  <jimb@zwingli.cygnus.com>

	Bug reports from Russ McManus:
	* guile-snarf.in: If the CPP environment variable is set, use that
	as the C preprocessor, instead of the preprocessor autoconf
	found.
	* snarf.h (SCM_PROC): Cast the function pointer passed to
	scm_make_gsubr, to satisfy C++.

Index: guile-snarf.in
===================================================================
RCS file: /egcs/carton/cvsfiles/guile/guile-core/libguile/guile-snarf.in,v
retrieving revision 1.3
diff -c -c -r1.3 guile-snarf.in
*** guile-snarf.in      1997/12/03 17:30:39     1.3
--- guile-snarf.in      1998/10/25 02:55:35
***************
*** 1,4 ****
  #!/bin/sh
  # Extract the initialization actions for builtin things.
  
! @CPP@ -DSCM_MAGIC_SNARFER "$@" | grep "^ *% *% *%" | sed -e "s/^ *% *% *%//"
--- 1,6 ----
  #!/bin/sh
  # Extract the initialization actions for builtin things.
  
! ## Let the user override the preprocessor autoconf found.
! test -n "${CPP+set}" || CPP="@CPP@"
! ${CPP} -DSCM_MAGIC_SNARFER "$@" | grep "^ *% *% *%" | sed -e "s/^ *% *% *%//"
Index: snarf.h
===================================================================
RCS file: /egcs/carton/cvsfiles/guile/guile-core/libguile/snarf.h,v
retrieving revision 1.9
diff -c -c -r1.9 snarf.h
*** snarf.h     1998/10/19 21:36:25     1.9
--- snarf.h     1998/10/25 02:55:35
***************
*** 55,61 ****
        static char RANAME[]=STR
  #else
  #define SCM_PROC(RANAME, STR, REQ, OPT, VAR, CFN)  \
! %%%   scm_make_gsubr (RANAME, REQ, OPT, VAR, CFN)
  #define SCM_PROC1(RANAME, STR, TYPE, CFN)  \
  %%%   scm_make_subr(RANAME, TYPE, CFN)
  #endif
--- 55,61 ----
        static char RANAME[]=STR
  #else
  #define SCM_PROC(RANAME, STR, REQ, OPT, VAR, CFN)  \
! %%%   scm_make_gsubr (RANAME, REQ, OPT, VAR, (SCM (*)()) CFN)
  #define SCM_PROC1(RANAME, STR, TYPE, CFN)  \
  %%%   scm_make_subr(RANAME, TYPE, CFN)
  #endif