Hello!

I merged that branch in ‘master’.

... and soon after I noticed this glitch with ‘SCM_DEFINE’: when
‘SCM_SUPPORT_STATIC_ALLOCATION’ is defined, it requires a previous C
declaration of the subr being defined.  For instance:

  SCM_DEFINE (foo, "foo", 1, 0, 0, (SCM x), "") { ... }

must now be preceded by:

  extern SCM foo (SCM);

This is not a problem in Guile core where we compile with
‘-Wmissing-prototypes’ and provide public declarations for all
‘SCM_DEFINE’d functions, but it may be a problem in projects that don’t.

This is easily remedied this way:

--- a/libguile/snarf.h
+++ b/libguile/snarf.h
@@ -101,14 +101,15 @@ SCM_SNARF_DOCS(primitive, FNAME, PRIMNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING)
 /* Static subr allocation.  */
 #define SCM_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING)	\
 SCM_SYMBOL (scm_i_paste (FNAME, __name), PRIMNAME);			\
-SCM_SNARF_HERE(								\
+SCM_SNARF_HERE(							\
   static const char scm_i_paste (s_, FNAME) [] = PRIMNAME;		\
+  extern SCM FNAME ARGLIST;						\
   SCM_IMMUTABLE_SUBR (scm_i_paste (FNAME, __subr),			\
 		      scm_i_paste (FNAME, __name),			\
 		      REQ, OPT, VAR, &FNAME);				\
   SCM FNAME ARGLIST							\
However, there are potentially 2 problems with this:

  1. The declaration could conflict with a previous, slightly different
     one.

     Apparently, a given function declaration and the same one decorated
     with GCC function attributes are considered the same, so this
     should be OK.  However, I’m slightly concerned about MSVC’s
     __declspec: does it work if it sees:

       __declspec(dllexport) extern SCM foo (SCM);
       extern SCM foo (SCM);

     If it works, that probably means this point is moot.

  2. The automatically added ‘extern’ declaration makes
     ‘-Wmissing-prototypes’ useless, which is annoying.

Thoughts?

Thanks,
Ludo’.

Reply via email to