Disclaimer: I am a complete newbie with C, but I\'ve been playing with it trying to mimic some features of classes. Ok, I know that if I want to go that way I should lea
A book (in PDF form) that explains how to do it, is object oriented programming in ANSI C It's old (1993) but still contains some valid ideas and tips, IMHO.
Various frameworks already exists. See for instance http://ldeniau.web.cern.ch/ldeniau/html/oopc.html
Did you have a look at Google's Go? It's basically a modernized C where things are done somewhat in the way you suggested. It has parameter polymorphisms. So you don't have to do this:
static void printFoo(struct foo self) {
printf("This is bar: %d\n", self.bar);
}
In Go it can be done this way:
static void print(Foo self) {
printf("This is foo: %d\n", self.foo);
}
static void print(Bar self) {
printf("This is bar: %d\n", self.bar);
}
In Go Foo and Bar would also be structs. So you are basically on the samet track as the Go language designers.
For an overview of Go see http://golang.org/doc/effective_go.html This is the Go main language description: http://golang.org/doc/effective_go.html