pointer casts
- From: Miroslaw Dobrzanski-Neumann <mne mosaic-ag com>
- To: GTKDEV <gtk-devel-list gnome org>
- Subject: pointer casts
- Date: Wed, 13 Mar 2002 13:17:54 +0100
Hi,
Compiling gclosure.c with DEC C V5.6-082 compiler I get the warnings listed
below (the same warnings are produced by the ibm xlc compiler). The problem is
that pointer to void is not the same as pointer to function. You can safe cast
data pointer but casting function pointer in i.e. pascal calling convention and
calling it afterwards as different ones produce a desaster.
After having take a look at the data types of the two sides of the assignemt I
wonder how it works.
gclosure.c:107 closure->marshal = (gpointer) ndata->notify;
the left side
=============
closure->marshal is of the type
typedef void (*GClosureMarshal) (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
the right side
==============
ndata->notify is of type
typedef void (*GClosureNotify) (gpointer data,
GClosure *closure);
assignment over (gpointer) cast makes gcc happy but not the other compiler.
cc: Warning: gclosure.c, line 107: In this statement, the referenced type of the pointer value "(gpointer)ndata->notify" is "void", which is not compatible with "function (pointer to struct _GClosure, pointer to struct _GValue, unsigned int, pointer to const struct _GValue, pointer to void, pointer to void) returning void".
closure->marshal = (gpointer) ndata->notify;
----------^
cc: Warning: gclosure.c, line 121: In this statement, the referenced type of the pointer value "(gpointer)ndata->notify" is "void", which is not compatible with "function (pointer to struct _GClosure, pointer to struct _GValue, unsigned int, pointer to const struct _GValue, pointer to void, pointer to void) returning void".
closure->marshal = (gpointer) ndata->notify;
----------^
cc: Warning: gclosure.c, line 475: In this statement, the referenced type of the pointer value "callback_func" is "function () returning void", which is not compatible with "void".
((GCClosure*) closure)->callback = callback_func;
--^
cc: Warning: gclosure.c, line 492: In this statement, the referenced type of the pointer value "callback_func" is "function () returning void", which is not compatible with "void".
((GCClosure*) closure)->callback = callback_func;
--^
Regards,
Miroslaw
--
Miroslaw Dobrzanski-Neumann
MOSAIC SOFTWARE AG
Base Development and Research
Tel +49-2225-882-291
Fax +49-2225-882-201
E-mail: mne mosaic-ag com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]