diff options
author | Pedro Alves <palves@redhat.com> | 2015-09-07 19:34:31 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-09-07 19:34:31 +0100 |
commit | 72e0248351fdc4ab125a16af24df031bca2275e4 (patch) | |
tree | ce243844c02fff130389d32ed3b7eeec23a0e3fd /gdb/guile/guile-internal.h | |
parent | 3d4fde6974a1237d79055ee734d99cc49c6fd3f9 (diff) | |
download | gdb-72e0248351fdc4ab125a16af24df031bca2275e4.zip gdb-72e0248351fdc4ab125a16af24df031bca2275e4.tar.gz gdb-72e0248351fdc4ab125a16af24df031bca2275e4.tar.bz2 |
guile: Add as_a_scm_t_subr
Building GDB in C++ mode on Fedora 20, the gdb/guile/ code shows ~280
errors like:
src/gdb/guile/guile.c:515:1: error: invalid conversion from ‘scm_unused_struct* (*)(SCM, SCM) {aka scm_unused_struct* (*)(scm_unused_struct*, scm_unused_struct*)}’ to ‘scm_t_subr {aka void*}’ [-fpermissive]
This commit fixes them all.
gdb/ChangeLog:
2015-09-07 Pedro Alves <palves@redhat.com>
* guile/guile-internal.h (as_a_scm_t_subr): New.
* guile/guile.c (misc_guile_functions): Use it.
* guile/scm-arch.c (arch_functions): Use it.
* guile/scm-block.c (block_functions, gdbscm_initialize_blocks):
Use it.
* guile/scm-breakpoint.c (breakpoint_functions): Use it.
* guile/scm-cmd.c (command_functions): Use it.
* guile/scm-disasm.c (disasm_functions): Use it.
* guile/scm-exception.c (exception_functions)
(private_exception_functions): Use it.
* guile/scm-frame.c (frame_functions)
* guile/scm-gsmob.c (gsmob_functions): Use it.
* guile/scm-iterator.c (iterator_functions): Use it.
* guile/scm-lazy-string.c (lazy_string_functions): Use it.
* guile/scm-math.c (math_functions): Use it.
* guile/scm-objfile.c (objfile_functions): Use it.
* guile/scm-param.c (parameter_functions): Use it.
* guile/scm-ports.c (port_functions, private_port_functions): Use
it.
* guile/scm-pretty-print.c (pretty_printer_functions): Use it.
* guile/scm-progspace.c (pspace_functions): Use it.
* guile/scm-string.c (string_functions): Use it.
* guile/scm-symbol.c (symbol_functions): Use it.
* guile/scm-symtab.c (symtab_functions): Use it.
* guile/scm-type.c (type_functions, gdbscm_initialize_types): Use
it.
* guile/scm-value.c (value_functions): Use it.
Diffstat (limited to 'gdb/guile/guile-internal.h')
-rw-r--r-- | gdb/guile/guile-internal.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h index 509120b..017309a 100644 --- a/gdb/guile/guile-internal.h +++ b/gdb/guile/guile-internal.h @@ -50,6 +50,50 @@ typedef struct #define END_VARIABLES { NULL, SCM_BOOL_F, NULL } +#ifdef __cplusplus + +/* Although scm_t_subr is meant to hold a function pointer, at least + in some versions of guile, it is actually a typedef to "void *". + That means that in C++, an explicit cast is necessary to convert + function pointer to scm_t_subr. But a cast also makes it possible + to pass function pointers with the wrong type by mistake. So + instead of adding such casts throughout, we use 'as_a_scm_t_subr' + to do the conversion, which (only) has overloads for function + pointer types that are valid. + + See https://lists.gnu.org/archive/html/guile-devel/2013-03/msg00001.html. +*/ + +static inline scm_t_subr +as_a_scm_t_subr (SCM (*func) (void)) +{ + return (scm_t_subr) func; +} + +static inline scm_t_subr +as_a_scm_t_subr (SCM (*func) (SCM)) +{ + return (scm_t_subr) func; +} + +static inline scm_t_subr +as_a_scm_t_subr (SCM (*func) (SCM, SCM)) +{ + return (scm_t_subr) func; +} + +static inline scm_t_subr +as_a_scm_t_subr (SCM (*func) (SCM, SCM, SCM)) +{ + return (scm_t_subr) func; +} + +#else + +/* In C, just do an implicit conversion. */ +#define as_a_scm_t_subr(func) func + +#endif /* Scheme functions to define during initialization. */ typedef struct |