HNHacker News
TopNewBestAskShowJobs

arquivo

3 karma · joined February 28, 2015

submissionscomments
arquivo··on Templating in C
http://pastebin.com/Wesjzs1A

...

arquivo··on Templating in C
I copied the function from the article, they are identical. This was done intentionally to show how convoluted the article is.
arquivo··on Templating in C
There is also a version with a normal function:

http://pastebin.com/Wesjzs1A

Solution in the article is overly convoluted.

arquivo··on Templating in 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.

arquivo··on Templating in C
Why complicate with multiple files, functions, defines and includes; here it is in one file with a single define:

http://pastebin.com/uWSs7ca7

We can improve the macro further by removing the unnecessary if statement and the index number:

http://pastebin.com/vPTTYPpe