Line 113 : t.my_struct_func = (_tmp0_ = __lambda0__my_delegate_func, ((t.my_struct_func_target_destroy_notify == NULL) ? NULL : (t.my_struct_func_target_destroy_notify (t.my_struct_func_target), NULL), t.my_struct_func = NULL, t.my_struct_func_target = NULL, t.my_struct_func_target_destroy_notify = NULL), t.my_struct_func_target = block1_data_ref (_data1_), t.my_struct_func_target_destroy_notify = block1_data_unref, _tmp0_);
test.c : /* test.c generated by valac, the Vala compiler * generated from test.vala, do not modify */ #include <glib.h> #include <glib-object.h> #include <stdlib.h> #include <string.h> #define TYPE_MY_STRUCT (my_struct_get_type ()) typedef struct _MyStruct MyStruct; #define _g_free0(var) (var = (g_free (var), NULL)) typedef struct _Block1Data Block1Data; typedef void (*myDelegateFunc) (void* user_data); struct _MyStruct { myDelegateFunc my_struct_func; gpointer my_struct_func_target; GDestroyNotify my_struct_func_target_destroy_notify; }; struct _Block1Data { int _ref_count_; char* a; }; GType my_struct_get_type (void); MyStruct* my_struct_dup (const MyStruct* self); void my_struct_free (MyStruct* self); void my_struct_copy (const MyStruct* self, MyStruct* dest); void my_struct_destroy (MyStruct* self); static void _lambda0_ (Block1Data* _data1_); static void __lambda0__my_delegate_func (gpointer self); static Block1Data* block1_data_ref (Block1Data* _data1_); static void block1_data_unref (Block1Data* _data1_); void _vala_main (void); void my_struct_copy (const MyStruct* self, MyStruct* dest) { dest->my_struct_func = self->my_struct_func; } void my_struct_destroy (MyStruct* self) { ((*self).my_struct_func_target_destroy_notify == NULL) ? NULL : ((*self).my_struct_func_target_destroy_notify ((*self).my_struct_func_target), NULL); self->my_struct_func = NULL; (*self).my_struct_func_target = NULL; (*self).my_struct_func_target_destroy_notify = NULL; } MyStruct* my_struct_dup (const MyStruct* self) { MyStruct* dup; dup = g_new0 (MyStruct, 1); my_struct_copy (self, dup); return dup; } void my_struct_free (MyStruct* self) { my_struct_destroy (self); g_free (self); } GType my_struct_get_type (void) { static volatile gsize my_struct_type_id__volatile = 0; if (g_once_init_enter (&my_struct_type_id__volatile)) { GType my_struct_type_id; my_struct_type_id = g_boxed_type_register_static ("MyStruct", (GBoxedCopyFunc) my_struct_dup, (GBoxedFreeFunc) my_struct_free); g_once_init_leave (&my_struct_type_id__volatile, my_struct_type_id); } return my_struct_type_id__volatile; } static void _lambda0_ (Block1Data* _data1_) { g_print ("%s", _data1_->a); } static void __lambda0__my_delegate_func (gpointer self) { _lambda0_ (self); } static Block1Data* block1_data_ref (Block1Data* _data1_) { ++_data1_->_ref_count_; return _data1_; } static void block1_data_unref (Block1Data* _data1_) { if ((--_data1_->_ref_count_) == 0) { _g_free0 (_data1_->a); g_slice_free (Block1Data, _data1_); } } void _vala_main (void) { Block1Data* _data1_; MyStruct t = {0}; myDelegateFunc _tmp0_; _data1_ = g_slice_new0 (Block1Data); _data1_->_ref_count_ = 1; _data1_->a = g_strdup ("test"); memset (&t, 0, sizeof (MyStruct)); t.my_struct_func = (_tmp0_ = __lambda0__my_delegate_func, ((t.my_struct_func_target_destroy_notify == NULL) ? NULL : (t.my_struct_func_target_destroy_notify (t.my_struct_func_target), NULL), t.my_struct_func = NULL, t.my_struct_func_target = NULL, t.my_struct_func_target_destroy_notify = NULL), t.my_struct_func_target = block1_data_ref (_data1_), t.my_struct_func_target_destroy_notify = block1_data_unref, _tmp0_); t.my_struct_func (t.my_struct_func_target); my_struct_destroy (&t); block1_data_unref (_data1_); } int main (int argc, char ** argv) { g_type_init (); _vala_main (); return 0; } Le jeudi 08 juillet 2010 à 00:29 +0100, Harry Van Haaren a écrit : > Hey Nicolas, > > Any chance you'd compile with valac --save-temps <your files etc > here>? > And then maybe post line 113 from your test.c file so we can see > what's really going on there? > > Cheers, -Harry > > On Thu, Jul 8, 2010 at 12:14 AM, Nicolas HENRY <ice...@gmail.com> > wrote: > Hello, > > I don't understand why this code produce a warning (vala > 0.9.2) : > > public delegate void myDelegateFunc(); > > struct MyStruct { > public myDelegateFunc my_struct_func; > } > > void main(){ > string a = "test"; > var t = MyStruct(); > t.my_struct_func = () => { > print(a); > }; > t.my_struct_func(); > } > > .../test.vala.c: In function ‘_vala_main’: > .../test.vala.c:113: warning: assignment from incompatible > pointer type > > Thanks. > > > _______________________________________________ > vala-list mailing list > vala-list@gnome.org > http://mail.gnome.org/mailman/listinfo/vala-list > _______________________________________________ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list