<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The C++ preprocessor &#8211; recursion</title>
	<atom:link href="http://nealabq.com/blog/2008/08/14/the-c-preprocessor-recursion/feed/" rel="self" type="application/rss+xml" />
	<link>http://nealabq.com/blog/2008/08/14/the-c-preprocessor-recursion/</link>
	<description>... dodging grues in the dark</description>
	<lastBuildDate>Fri, 30 Mar 2012 09:37:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Mykhailo</title>
		<link>http://nealabq.com/blog/2008/08/14/the-c-preprocessor-recursion/comment-page-1/#comment-63</link>
		<dc:creator>Mykhailo</dc:creator>
		<pubDate>Wed, 29 Oct 2008 00:36:48 +0000</pubDate>
		<guid isPermaLink="false">http://nealabq.com/blog/?p=269#comment-63</guid>
		<description>Neal,

Gosh! adapting the C++ preprocessor is too big a gun for such a small sparrow :-). I just wanted to make my header files report themselves to some kind of static metainformation manager. But still thank you for pointing out this alternative!

Yes, I&#039;ve resorted to template specialization and killed two birds with one stone, namely implemented both a meaningful global static assertion mechanism (by using the &#039;sizeof&#039; operator on an undefined specialized template class) AND my beloved recursion to solve the above-mentioned challenge. With a little bit of boilerplate code pasted into each header, I&#039;ve achieved reasonably good results.

I knew of the Boost library before but haven&#039;t managed to find a proper library that would do what I needed.

Thanks for your brilliant and compendious answer and cheers!
Mykhailo</description>
		<content:encoded><![CDATA[<p>Neal,</p>
<p>Gosh! adapting the C++ preprocessor is too big a gun for such a small sparrow :-). I just wanted to make my header files report themselves to some kind of static metainformation manager. But still thank you for pointing out this alternative!</p>
<p>Yes, I&#8217;ve resorted to template specialization and killed two birds with one stone, namely implemented both a meaningful global static assertion mechanism (by using the &#8216;sizeof&#8217; operator on an undefined specialized template class) AND my beloved recursion to solve the above-mentioned challenge. With a little bit of boilerplate code pasted into each header, I&#8217;ve achieved reasonably good results.</p>
<p>I knew of the Boost library before but haven&#8217;t managed to find a proper library that would do what I needed.</p>
<p>Thanks for your brilliant and compendious answer and cheers!<br />
Mykhailo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neal</title>
		<link>http://nealabq.com/blog/2008/08/14/the-c-preprocessor-recursion/comment-page-1/#comment-62</link>
		<dc:creator>Neal</dc:creator>
		<pubDate>Tue, 28 Oct 2008 20:52:31 +0000</pubDate>
		<guid isPermaLink="false">http://nealabq.com/blog/?p=269#comment-62</guid>
		<description>The first thing I&#039;d do is try to use templates instead of macros.
You can do some amazing things with templates, and recursion is not a problem. I&#039;ve written about templates a couple times here, and the Boost libraries have a lot of complicated examples. Look at the &lt;a href=&quot;http://www.boost.org/doc/libs/1_36_0/libs/type_traits/doc/html/index.html&quot; rel=&quot;nofollow&quot;&gt;type_traits&lt;/a&gt;, &lt;a href=&quot;http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/index.html&quot; rel=&quot;nofollow&quot;&gt;MPL&lt;/a&gt;, and &lt;a href=&quot;http://www.boost.org/doc/libs/1_36_0/libs/fusion/doc/html/index.html&quot; rel=&quot;nofollow&quot;&gt;Fusion&lt;/a&gt; libraries.

If templates won&#039;t solve your problem and you need the preprocessor to get down to the tokens, take a look at &lt;a href=&quot;http://www.boost.org/doc/libs/1_36_0/libs/preprocessor/doc/index.html&quot; rel=&quot;nofollow&quot;&gt;the Boost Preprocessor library.&lt;/a&gt; It let&#039;s you simulate recursion pretty well. I&#039;ve written about it &lt;a href=&quot;http://nealabq.com/blog/2008/10/07/using-boost_pp_macros/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.

Or as a last resort you could write your own preprocessor. It&#039;s not as hard as it sounds because you just have to modify an open-source (embeddable) preprocessor/tokenizer. Sounds easy, eh ;-). See &lt;a href=&quot;http://www.boost.org/doc/libs/1_36_0/libs/wave/index.html&quot; rel=&quot;nofollow&quot;&gt;Wave&lt;/a&gt;, which is based on &lt;a href=&quot;http://www.boost.org/doc/libs/1_36_0/libs/spirit/classic/index.html&quot; rel=&quot;nofollow&quot;&gt;Spirit&lt;/a&gt;.

Let me know if any of this works out, of if you find something else interesting.</description>
		<content:encoded><![CDATA[<p>The first thing I&#8217;d do is try to use templates instead of macros.<br />
You can do some amazing things with templates, and recursion is not a problem. I&#8217;ve written about templates a couple times here, and the Boost libraries have a lot of complicated examples. Look at the <a href="http://www.boost.org/doc/libs/1_36_0/libs/type_traits/doc/html/index.html" rel="nofollow">type_traits</a>, <a href="http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/index.html" rel="nofollow">MPL</a>, and <a href="http://www.boost.org/doc/libs/1_36_0/libs/fusion/doc/html/index.html" rel="nofollow">Fusion</a> libraries.</p>
<p>If templates won&#8217;t solve your problem and you need the preprocessor to get down to the tokens, take a look at <a href="http://www.boost.org/doc/libs/1_36_0/libs/preprocessor/doc/index.html" rel="nofollow">the Boost Preprocessor library.</a> It let&#8217;s you simulate recursion pretty well. I&#8217;ve written about it <a href="http://nealabq.com/blog/2008/10/07/using-boost_pp_macros/" rel="nofollow">here</a>.</p>
<p>Or as a last resort you could write your own preprocessor. It&#8217;s not as hard as it sounds because you just have to modify an open-source (embeddable) preprocessor/tokenizer. Sounds easy, eh ;-). See <a href="http://www.boost.org/doc/libs/1_36_0/libs/wave/index.html" rel="nofollow">Wave</a>, which is based on <a href="http://www.boost.org/doc/libs/1_36_0/libs/spirit/classic/index.html" rel="nofollow">Spirit</a>.</p>
<p>Let me know if any of this works out, of if you find something else interesting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mykhailo</title>
		<link>http://nealabq.com/blog/2008/08/14/the-c-preprocessor-recursion/comment-page-1/#comment-61</link>
		<dc:creator>Mykhailo</dc:creator>
		<pubDate>Sat, 25 Oct 2008 08:41:09 +0000</pubDate>
		<guid isPermaLink="false">http://nealabq.com/blog/?p=269#comment-61</guid>
		<description>Thanks for the very good elucidation on the topic, but if I DO want to use recursion in my macros, are there any chances for me to find a workaround?</description>
		<content:encoded><![CDATA[<p>Thanks for the very good elucidation on the topic, but if I DO want to use recursion in my macros, are there any chances for me to find a workaround?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

