Add `scm_t_subr' typedef (fix bug #23681).
authorLudovic Courtès <ludo@gnu.org>
Sun, 13 Feb 2011 13:50:05 +0000 (14:50 +0100)
committerLudovic Courtès <ludo@gnu.org>
Sun, 13 Feb 2011 13:50:05 +0000 (14:50 +0100)
* libguile/__scm.h (scm_t_subr): New typedef.

* libguile/deprecated.h (scm_make_gsubr, scm_make_gsubr_with_generic,
  scm_call_catching_errors): Use it.

* libguile/gsubr.h (scm_c_make_gsubr, scm_c_define_gsubr,
  scm_c_define_gsubr_with_generic): Likewise.

* libguile/smob.h (scm_smob_descriptor)[apply]: Likewise.
  (scm_set_smob_apply): Likewise.

* libguile/snarf.h (SCM_FUNC_CAST_ARBITRARY_ARGS): Likewise.

libguile/__scm.h
libguile/deprecated.h
libguile/gsubr.h
libguile/smob.h
libguile/snarf.h

index efdab6d..2bfb4f6 100644 (file)
@@ -3,7 +3,8 @@
 #ifndef SCM___SCM_H
 #define SCM___SCM_H
 
-/* Copyright (C) 1995,1996,1998,1999,2000,2001,2002,2003, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2006,
+ *   2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
 
 #include "libguile/tags.h"
 
+
+/* 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).  */
+
+#ifdef BUILDING_LIBGUILE
+typedef SCM (* scm_t_subr) ();
+#else
+typedef void *scm_t_subr;
+#endif
+
 \f
 #ifdef vms
 # ifndef CHEAP_CONTINUATIONS
index 68aee63..7deee35 100644 (file)
@@ -133,12 +133,12 @@ SCM_DEPRECATED SCM scm_internal_with_fluids (SCM fluids, SCM vals,
 
 SCM_DEPRECATED SCM scm_make_gsubr (const char *name,
                                   int req, int opt, int rst,
-                                  SCM (*fcn)());
+                                  scm_t_subr fcn);
 SCM_DEPRECATED SCM scm_make_gsubr_with_generic (const char *name,
                                                int req,
                                                int opt,
                                                int rst,
-                                               SCM (*fcn)(),
+                                               scm_t_subr fcn,
                                                SCM *gf);
 
 SCM_DEPRECATED SCM scm_create_hook (const char* name, int n_args);
@@ -173,7 +173,8 @@ SCM_DEPRECATED SCM scm_read_and_eval_x (SCM port);
 
 #define SCM_SUBR_DOC(x) SCM_BOOL_F
 
-SCM_DEPRECATED SCM scm_call_catching_errors (SCM (*thunk)(), SCM (*err_filter)(),
+SCM_DEPRECATED SCM scm_call_catching_errors (scm_t_subr thunk,
+                                            scm_t_subr err_filter,
                                             void * closure);
 
 SCM_DEPRECATED long scm_make_smob_type_mfpe (char *name, size_t size,
index faa4bb0..5adffa4 100644 (file)
@@ -3,7 +3,8 @@
 #ifndef SCM_GSUBR_H
 #define SCM_GSUBR_H
 
-/* Copyright (C) 1995,1996,1998,2000,2001, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1998, 2000, 2001, 2006, 2008, 2009,
+ *   2010, 2011 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -59,16 +60,16 @@ SCM_API SCM scm_subr_objcode_trampoline (unsigned int nreq,
 
 \f
 
-SCM_API SCM scm_c_make_gsubr (const char *name, 
-                             int req, int opt, int rst, SCM (*fcn) ());
+SCM_API SCM scm_c_make_gsubr (const char *name,
+                             int req, int opt, int rst, scm_t_subr fcn);
 SCM_API SCM scm_c_make_gsubr_with_generic (const char *name,
                                           int req, int opt, int rst,
-                                          SCM (*fcn) (), SCM *gf);
-SCM_API SCM scm_c_define_gsubr (const char *name, 
-                               int req, int opt, int rst, SCM (*fcn) ());
+                                          scm_t_subr fcn, SCM *gf);
+SCM_API SCM scm_c_define_gsubr (const char *name,
+                               int req, int opt, int rst, scm_t_subr fcn);
 SCM_API SCM scm_c_define_gsubr_with_generic (const char *name,
                                             int req, int opt, int rst,
-                                            SCM (*fcn) (), SCM *gf);
+                                            scm_t_subr fcn, SCM *gf);
 
 SCM_INTERNAL void scm_init_gsubr (void);
 
index 07deebd..6a7ceea 100644 (file)
@@ -3,7 +3,8 @@
 #ifndef SCM_SMOB_H
 #define SCM_SMOB_H
 
-/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2004, 2006, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2004, 2006, 2009,
+ *   2010, 2011 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -40,7 +41,7 @@ typedef struct scm_smob_descriptor
   size_t (*free) (SCM);
   int (*print) (SCM exp, SCM port, scm_print_state *pstate);
   SCM (*equalp) (SCM, SCM);
-  SCM (*apply) ();
+  scm_t_subr apply;
   SCM apply_trampoline_objcode;
 } scm_smob_descriptor;
 
@@ -202,7 +203,7 @@ SCM_API void scm_set_smob_print (scm_t_bits tc,
                                 int (*print) (SCM, SCM, scm_print_state*));
 SCM_API void scm_set_smob_equalp (scm_t_bits tc, SCM (*equalp) (SCM, SCM));
 SCM_API void scm_set_smob_apply (scm_t_bits tc,
-                                SCM (*apply) (),
+                                scm_t_subr apply,
                                 unsigned int req,
                                 unsigned int opt,
                                 unsigned int rst);
index fcd0173..9bb998e 100644 (file)
@@ -3,7 +3,8 @@
 #ifndef SCM_SNARF_H
 #define SCM_SNARF_H
 
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2004, 2006, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+ *   2004, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
 
 /* Macros for snarfing initialization actions from C source. */
 
-#if defined(__cplusplus) || defined(GUILE_CPLUSPLUS_SNARF)
+/* Casting to a function that can take any number of arguments.  */
+#define SCM_FUNC_CAST_ARBITRARY_ARGS  scm_t_subr
 
-/* This used to be "SCM (*)(...)" but GCC on RedHat 7.1 doesn't seem
-   to like it.
- */
-#define SCM_FUNC_CAST_ARBITRARY_ARGS SCM (*)()
-
-#else
-#define SCM_FUNC_CAST_ARBITRARY_ARGS SCM (*)()
-#endif
 
 #if (defined SCM_ALIGNED) && (SCM_DEBUG_TYPING_STRICTNESS <= 1)
 /* We support static allocation of some `SCM' objects.  */