G_OBJECT vs GTK_OBJECT

http://ts-hoop.blogspot.com/2008/03/gtkcasting.html的

看GTK的Casting发现一个小问题

提到这两个型别转换的问题,看了 Foundations of GTK+ Development的课本后,才发现这应该是版本的问题。

GObject is the fundamental type providing common attributes for all libraries based
on it including GTK+ and Pango. It allows objects derived from it to be constructed,
destroyed, referenced, and unreferenced. It also provides the signal system and object
property functions. You can cast an object as a GObject with G_OBJECT(). If you try to
cast an object with G_OBJECT() that is not a GObject or derived from it, GLib will throw a
critical error, and the cast will fail. This will occur with any other GTK+ casting function.

GtkObject is the base class for all GTK+ objects. It was replaced as the absolute base
class of all objects in GTK+ 2.0, but GtkObject was kept for backward compatibility of
nonwidget classes like GtkAdjustment. You can cast an object as a GtkObject with
GTK_OBJECT().