Macros are a very useful feature of the C preprocessor for reducing boilerplate. It is well known that they have limited processing power; most importantly, they cannot recurse, and cannot iterate over lists. Libraries for meta-programming (e.g. Boost.Preprocessor and metalang99) work around this, but are only capable of executing a limited number of iterations, and have complex implementations. However, an obscure GCC feature can be abused to allow for “true” recursion in macros in a relatively elegant manner, allowing more complex and useful macros to be implemented.
read more…