Hi David, David Fang <f...@csl.cornell.edu> writes:
> /* The type of subrs, i.e., Scheme procedures implemented in C. Empty > function declarators are used internally for pointers to functions of > any arity. However, these are equivalent to `(void)' in C++, are > obsolescent as of C99, and trigger `strict-prototypes' GCC warnings > (bug #23681). */ (See <http://savannah.gnu.org/bugs/?23681>.) > #ifdef BUILDING_LIBGUILE > typedef SCM (* scm_t_subr) (); > #else > typedef void *scm_t_subr; > #endif [...] > and after installation, BUILDING_LIBGUILE is no longer defined. Had > the typedef been kept as SCM (*scm_t_subr)(), then the C++ compiler > would have no reason to complain As explained above, it would complain because in C++ an empty declarator means that the function takes zero arguments, whereas in C it means that the function prototype is undefined—i.e., the function can take any number of arguments of any type. If you think the comment can be improved, please let me know. > cc1plus: warnings being treated as errors > ../../../src/guile/hackt-config.cc: In function 'void > HAC::guile_wrap::wrap_package_string_init()': > ../../../src/guile/hackt-config.cc:32: warning: ISO C++ forbids > casting between pointer-to-function and pointer-to-object In C++, instead of writing, say: --8<---------------cut here---------------start------------->8--- extern SCM bar (SCM x, SCM y); ... scm_c_define_gsubr ("foo", 1, 2, 3, &bar); --8<---------------cut here---------------end--------------->8--- you must write: --8<---------------cut here---------------start------------->8--- extern SCM bar (SCM x, SCM y); ... scm_c_define_gsubr ("foo", 1, 2, 3, (scm_t_subr) &bar); --8<---------------cut here---------------end--------------->8--- (Tested with G++ 4.5.1 -Wall.) If you use ‘guile-snarf’, it should do the right thing. Hope this helps, Ludo’.