<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://nick-black.com/dankwiki/index.php?action=history&amp;feed=atom&amp;title=X_Macros</id>
	<title>X Macros - revision history</title>
	<link rel="self" type="application/atom+xml" href="https://nick-black.com/dankwiki/index.php?action=history&amp;feed=atom&amp;title=X_Macros"/>
	<link rel="alternate" type="text/html" href="https://nick-black.com/dankwiki/index.php?title=X_Macros&amp;action=history"/>
	<updated>2026-10-31T08:24:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://nick-black.com/dankwiki/index.php?title=X_Macros&amp;diff=6242&amp;oldid=prev</id>
		<title>Dank at 20:32, 3 August 2019</title>
		<link rel="alternate" type="text/html" href="https://nick-black.com/dankwiki/index.php?title=X_Macros&amp;diff=6242&amp;oldid=prev"/>
		<updated>2019-08-03T20:32:17Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:32, 3 August 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The C/C++ preprocessor expands a nested macro only when the subsuming macro is expanded, as opposed to defined. It also allows macros to be redefined. This leads to an elegant and powerful technique, not used nearly widely enough, for eliminating unmaintainable duplications. The problem originates in C&#039;s divergent (tetrapartite, to be precise) syntactic namespace:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[ISO C99|&lt;/ins&gt;C&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]]&lt;/ins&gt;/C++ preprocessor expands a nested macro only when the subsuming macro is expanded, as opposed to defined. It also allows macros to be redefined. This leads to an elegant and powerful technique, not used nearly widely enough, for eliminating unmaintainable duplications. The problem originates in C&#039;s divergent (tetrapartite, to be precise) syntactic namespace:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Aggregates (names of &amp;lt;tt&amp;gt;structs&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;unions&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;enums&amp;lt;/tt&amp;gt;)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Aggregates (names of &amp;lt;tt&amp;gt;structs&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;unions&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;enums&amp;lt;/tt&amp;gt;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Members within each aggregate&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Members within each aggregate&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wikidb:diff:1.41:old-3319:rev-6242:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Dank</name></author>
	</entry>
	<entry>
		<id>https://nick-black.com/dankwiki/index.php?title=X_Macros&amp;diff=3319&amp;oldid=prev</id>
		<title>Dank: that looked retarded</title>
		<link rel="alternate" type="text/html" href="https://nick-black.com/dankwiki/index.php?title=X_Macros&amp;diff=3319&amp;oldid=prev"/>
		<updated>2010-08-08T20:46:40Z</updated>

		<summary type="html">&lt;p&gt;that looked retarded&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:46, 8 August 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The C/C++ preprocessor expands a nested macro only when the subsuming macro is expanded, as opposed to defined. It also allows macros to be redefined. This leads to an elegant and powerful technique, not used nearly widely enough, for eliminating unmaintainable duplications. The problem originates in C&amp;#039;s divergent (tetrapartite, to be precise) syntactic namespace:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The C/C++ preprocessor expands a nested macro only when the subsuming macro is expanded, as opposed to defined. It also allows macros to be redefined. This leads to an elegant and powerful technique, not used nearly widely enough, for eliminating unmaintainable duplications. The problem originates in C&amp;#039;s divergent (tetrapartite, to be precise) syntactic namespace:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Aggregates (names of &amp;lt;tt&amp;gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;struct&lt;/del&gt;&amp;lt;/tt&amp;gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;s&lt;/del&gt;, &amp;lt;tt&amp;gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;union&lt;/del&gt;&amp;lt;/tt&amp;gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;s&lt;/del&gt;, and &amp;lt;tt&amp;gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;enum&lt;/del&gt;&amp;lt;/tt&amp;gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;s&lt;/del&gt;)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Aggregates (names of &amp;lt;tt&amp;gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;structs&lt;/ins&gt;&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;unions&lt;/ins&gt;&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;enums&lt;/ins&gt;&amp;lt;/tt&amp;gt;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Members within each aggregate&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Members within each aggregate&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Labels&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Labels&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dank</name></author>
	</entry>
	<entry>
		<id>https://nick-black.com/dankwiki/index.php?title=X_Macros&amp;diff=189&amp;oldid=prev</id>
		<title>WikiSysop: 1 revision</title>
		<link rel="alternate" type="text/html" href="https://nick-black.com/dankwiki/index.php?title=X_Macros&amp;diff=189&amp;oldid=prev"/>
		<updated>2009-01-28T07:32:17Z</updated>

		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:32, 28 January 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikidb:diff:1.41:old-188:rev-189 --&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://nick-black.com/dankwiki/index.php?title=X_Macros&amp;diff=188&amp;oldid=prev</id>
		<title>Dank at 08:08, 4 May 2008</title>
		<link rel="alternate" type="text/html" href="https://nick-black.com/dankwiki/index.php?title=X_Macros&amp;diff=188&amp;oldid=prev"/>
		<updated>2008-05-04T08:08:17Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The C/C++ preprocessor expands a nested macro only when the subsuming macro is expanded, as opposed to defined. It also allows macros to be redefined. This leads to an elegant and powerful technique, not used nearly widely enough, for eliminating unmaintainable duplications. The problem originates in C&amp;#039;s divergent (tetrapartite, to be precise) syntactic namespace:&lt;br /&gt;
* Aggregates (names of &amp;lt;tt&amp;gt;struct&amp;lt;/tt&amp;gt;s, &amp;lt;tt&amp;gt;union&amp;lt;/tt&amp;gt;s, and &amp;lt;tt&amp;gt;enum&amp;lt;/tt&amp;gt;s)&lt;br /&gt;
* Members within each aggregate&lt;br /&gt;
* Labels&lt;br /&gt;
* Ordinary identifiers&lt;br /&gt;
It can be difficult to ensure bijections defined between, say, the members of an enumeration and two mutually-exclusive constant, statically-initialized arrays of structures remain preserved across changes to the code. This is, of course, the central problem of duplication. Eliminating the redundancy seems impossible (without explicitly-coded runtime checks, and the associated assurance problems and performance penalties): Designated initializers can ensure that reorderings are preserved and that deletions result in compilation failures, but they fail to address augmentations in any one set; the bijection can be violated when members are added.&lt;br /&gt;
&lt;br /&gt;
==Case study==&lt;br /&gt;
Check section 2.4.3 of [http://people.redhat.com/drepper/dsohowto.pdf &amp;quot;How to Write Shared Libraries&amp;quot;] by [[glibc]] maintainer Ulrich Drepper. The &amp;quot;Arrays of Data Pointers&amp;quot; solution provided therein is optimal for constant strings of common length, but an unmaintainable eyesore. X macros address this problem exquisitely. I was going to write up a solution, until I realized Appendix B of aforementioned paper already contains one, credited to Bruno Haible. Well, there you go.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [http://www.ddj.com/cpp/184401387 The New C: X Macros] &amp;#039;&amp;#039;Dr. Dobb&amp;#039;s&amp;#039;&amp;#039; 2001-05-01&lt;/div&gt;</summary>
		<author><name>Dank</name></author>
	</entry>
</feed>