C Preprocessor Hell
jacquesmattheij.com
C Preprocessor Hell
1–10 of 30 posts
Re: C Preprocessor Hell
#2Re: C Preprocessor Hell
#3The ## in front of __VA_ARGS__ is a gcc extension.
Re: C Preprocessor Hell
#4X-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
#5The 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.
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.
Re: C Preprocessor Hell
#6You aren't required to only use the C source code transformation tools that a default install of GCC provides.
Re: C Preprocessor Hell
#7Naive question: in Lisp, how would you set the byte at address 0xDEADBEEF to 0x42?
Re: C Preprocessor Hell
#8I don't know why people don't seem to think of this when confronted with the limitations of the standard C preprocessor, but Perl or Lisp both make excellent C preprocessors. You aren't required to only use the C source code transformation tools that a default install of GCC provides.
If you're about to reply it's a risk you'd take... me too, in general. CPP sucks. But not wanting to introduce that risk is a valid choice in many cases.
Re: C Preprocessor Hell
#9I don't know why people don't seem to think of this when confronted with the limitations of the standard C preprocessor, but Perl or Lisp both make excellent C preprocessors. You aren't required to only use the C source code transformation tools that a default install of GCC provides.
Re: C Preprocessor Hell
#10I don't know why people don't seem to think of this when confronted with the limitations of the standard C preprocessor, but Perl or Lisp both make excellent C preprocessors. You aren't required to only use the C source code transformation tools that a default install of GCC provides.