天天看點

specified class size for type `CatType' is smaller than the parent type's `GObject

編寫了一個小小的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;

    ..........................

};

就好了

繼續閱讀