News for hackers. Stuff that matters.
Re:C Preprocessor Hell by ge0rg on Thursday January 12, 2012 @07:52AM (#3456134)
The code in the article is actually less horrible than I expected from the title. However, it seems like a situation which could be more elegantly solved with X-Macros (http://drdobbs.com/cpp/184401387), provided that you consider X-Macros elegant.

X-Macros: you have a header file consisting of lines in the form of "FOO(name, type, defvalue);" and include it several times with different definitions for FOO.

Re:C Preprocessor Hell by jacquesm on Thursday January 12, 2012 @09:14AM (#3456349)
I don't particularly like include files in the middle of structs, but it looks like X macros might work.

Thanks for the tip, I'll have a look at them to see if there is a way around that so that it would work from a 'top' included file as well.

The project I'm working on has a single 'master include' file and I'd hate to break that convention.