編寫了一個小小的Gobject程序,運行是出現錯誤:
(process:23258): GLib-GObject-WARNING **: specified class size for type `CatType' is smaller than the parent type's `GObject' class size
type = 0-----------------------------------g_type_register_static的返回爲0
(process:23258): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
查了好久,突然發現原來錯在:
struct _Cat
{
GTypeInstance parent;
.......................
};
struct _CatClass
{
GTypeClass parent_class;
..........................
};
分別改成是:
struct _Cat
{
GObject parent;
.......................
};
struct _CatClass
{
GObjectClass parent_class;
..........................
};
就好了
specified class size for type `CatType' is smaller than the parent type's `GObject
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.