Re:Templating in C
by motoki88 on Saturday February 28, 2015 @01:08PM
(#9124453)
I am looking for a book or web page which describes well programming patterns in C (might be focused on OOP in C). I mostly design for embedded systems.
Any recomendations?
[ Parent
| on HN ]
Re:Templating in C
by michaelcampbell on Saturday February 28, 2015 @01:27PM
(#9124504)
More of a general (i.e., not embedded systems specific) book on C is "Deep C Secrets", by Peter Van Der Linden.
Amazon link: http://www.amazon.com/Expert-Programming-Peter-van-Linden/dp...
An excellent book, and one which stands right next to K&R in my opinion, as a standard reference book on the subject of the C language. It still has much relevance today - many C projects I've seen being written by the new generation of developers could benefit from having this book become standard reference material everywhere. I can't recommend it enough.
Re:Templating in C
by ndesaulniers on Saturday February 28, 2015 @05:32PM
(#9125308)
This is an excellent book...but I would not recommend it to beginners. Read "Head First C" first, then maybe this book. Would also recommend "21st Century C."
Take a look at Object Oriented Programming With ANSI-C.
http://www.cs.rit.edu/~ats/books/
It is complicated, but you can take parts from it and built your own system.
I've actually used a subset of that book for on an embedded system. It ended up being scrapped, partly due to project management issues and partly because we were writing twice as much code for very little benefit, so I can't say I recommend it for embedded projects. The need for malloc was a pretty big negative as well.
That said, I would recommend it as a good learning experience.
why do you need malloc here?
Looking the PDF over again you don't need malloc, that was a quirk of our implementation. We had separated public/private structs, meaning private variables were inaccessible by non-class methods (and thus also unable to be instantiated statically by other code modules.)
(Our implementation was not very good.)