This is the mail archive of the guile@sourceware.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: Another const PATCH plus problems with gh_new_procedure


On 9 Dec 1999, Greg J. Badros wrote:

> Dirk Herrmann <dirk@ida.ing.tu-bs.de> writes:
> 
> > SWIG has generated the following code:
> >   gh_new_procedure("foo", _wrap_gscm_foo, 3, 0, 0);
> > where _wrap_gscm_foo has the following prototype:
> >   SCM _wrap_gscm_foo(SCM s_0,SCM s_1,SCM s_2);
> > Then the C++ compiler complains:
> >   ANSI C++ prohibits conversion from `(long int, long int, long int)' to `(...)'
> > 
> > The reason is, that gh_new_procedure accepts any function as its second
> > parameter:  SCM (*fn)(), which basically means SCM (*fn)(...).  However, for
> > ANSI C++ it seems not to be allowed to pass a SCM (*fn)(SCM,SCM,SCM) as a
> > parameter when a SCM (*fn)(...) is required.
> > 
> > Wrapping include<gh.h> with extern "C" did not help.
> > 
> > Any ideas for a solution?
> 
> In scwm-snarf.h, I force scwm_make_gsubr to cast the function argument
> to (SCM (*)(...)) when it expands the registration of the procedure.  I
> did the same thing for guile's snarf.h and that works for SCM_PROC
> macros.  You could make SWIG generate the cast in the call to
> gh_new_procedure.  I don't think C++ has any way to turn off that
> argument checking globallly-- I believe each invocation needs the cast
> since it is relying on the undefined (but well-supported) "feature" that 
> the two function pointers look the same in memory.

Thanks for your help.  I incorporated this change into SWIG, but with the
extension, that it now produces gh_new_procedure<x>_0 calls for all functions
with up to 5 parameters, thus reducing the need for casting only to the
other cases.

These patches are against swig1.1p5.  Thus, if anybody is interested in these,
i'd be glad to provide them to you.  I would also like to add them to the
newest release of SWIG (if there will still be guile support in it) as soon as
this one gets available.

Dirk


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