It's very doable, though C++ is arguably cleaner. Xlib contains a few OO principles, and GTK+ even more. Both are written in ANSI C. And let's not forget the UNIX concept of the file descriptor (which can be a file, device, pipe, or socket)
"
Methods" are done in the form
objectname_action(), and the
first arg is usually an
object, a la the
this pointer. "
Constructors" are done as
objectname_new(),
destructor is
objectname_destroy(),
et cetera. There are
relatively ugly ways to have
multiple constructors and
methods that do the same thing but take
different args, like the
GTK+ functions
gtk_button_new_with_label() and
gtk_object_set_data_full().
One way to achieve OO is to typedef each object type as int (a descriptor) and have some sort of global data structure for each type of object, to use as your private data. For inheritance, you just make a new typedef, global data structure, and set of methods. And since all objects are really an int, all existing methods should work on an inherited object.
Another way for an object model in ANSI C is based on struct pointers. This is somewhat harder to do with inheritance, but GTK+ manages.
Either way,
C++ and the like are probably a lot
easier.