<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.neelanurseries.com/index.php?action=history&amp;feed=atom&amp;title=Macros</id>
	<title>Macros - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.neelanurseries.com/index.php?action=history&amp;feed=atom&amp;title=Macros"/>
	<link rel="alternate" type="text/html" href="https://wiki.neelanurseries.com/index.php?title=Macros&amp;action=history"/>
	<updated>2026-05-29T23:28:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.neelanurseries.com/index.php?title=Macros&amp;diff=9010&amp;oldid=prev</id>
		<title>Ted: Add link to Jens Gustedt Wordpress article on Empty Macro Detection</title>
		<link rel="alternate" type="text/html" href="https://wiki.neelanurseries.com/index.php?title=Macros&amp;diff=9010&amp;oldid=prev"/>
		<updated>2026-05-27T22:00:30Z</updated>

		<summary type="html">&lt;p&gt;Add link to Jens Gustedt Wordpress article on Empty Macro Detection&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&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 22:00, 27 May 2026&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-l62&quot; &gt;Line 62:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 62:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&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;./include/zephyr/devicetree.h:4544:#define DT_INST_FOREACH_STATUS_OKAY_VARGS(fn, ...) \&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;./include/zephyr/devicetree.h:4544:#define DT_INST_FOREACH_STATUS_OKAY_VARGS(fn, ...) \&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&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;```&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;```&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Related to Zephyr RTOS sys util macros and Zephyr&amp;#039;s _COND_CODE_1 and _COND_CODE_0 macros:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;*  [https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ Jens Gustedt Wordpress article Empty Macro Detection]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&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;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&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;=== [[#top|^]] CONTAINER_OF macro ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;=== [[#top|^]] CONTAINER_OF macro ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Ted</name></author>
	</entry>
	<entry>
		<id>https://wiki.neelanurseries.com/index.php?title=Macros&amp;diff=9009&amp;oldid=prev</id>
		<title>Ted: Amend opening paragraph</title>
		<link rel="alternate" type="text/html" href="https://wiki.neelanurseries.com/index.php?title=Macros&amp;diff=9009&amp;oldid=prev"/>
		<updated>2026-05-27T21:46:21Z</updated>

		<summary type="html">&lt;p&gt;Amend opening paragraph&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&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 21:46, 27 May 2026&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=&#039;diff-marker&#039;&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;Macros - C Preprocessor Macro language   &lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;Macros - C Preprocessor Macro language   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;C&amp;#039;s preprocessor language is an important feature and tool in the development space of C language projects.  This local wiki page captures some references to preprocessor macro language.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== [[#top|^]] General Articles about Macros ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&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;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&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;Some general and comprehensive discussions of C macros can be found at:&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&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;Some general and comprehensive discussions of C macros can be found at:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Ted</name></author>
	</entry>
	<entry>
		<id>https://wiki.neelanurseries.com/index.php?title=Macros&amp;diff=9008&amp;oldid=prev</id>
		<title>Ted: Create local page for C preprocessor macros</title>
		<link rel="alternate" type="text/html" href="https://wiki.neelanurseries.com/index.php?title=Macros&amp;diff=9008&amp;oldid=prev"/>
		<updated>2026-05-27T21:42:30Z</updated>

		<summary type="html">&lt;p&gt;Create local page for C preprocessor macros&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Macros - C Preprocessor Macro language  &lt;br /&gt;
&lt;br /&gt;
Some general and comprehensive discussions of C macros can be found at:&lt;br /&gt;
&lt;br /&gt;
# https://home.cs.colorado.edu/~main/cs1300/doc/gnu/cpp_1.html&lt;br /&gt;
# https://stackoverflow.com/questions/4674480/do-whilefalse-pattern&amp;lt;br /&amp;gt;&lt;br /&gt;
# https://www.mikeash.com/pyblog/friday-qa-2010-12-31-c-macro-tips-and-tricks.html&amp;lt;br /&amp;gt;&lt;br /&gt;
# https://en.wikipedia.org/wiki/C_preprocessor#X-Macros&amp;lt;br /&amp;gt;&lt;br /&gt;
# https://en.wikipedia.org/wiki/X_macro&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== [[#top|^]] do while(0) ===&lt;br /&gt;
&lt;br /&gt;
Articles on the use of C language &amp;#039;do while(0)&amp;#039; construct in macros.  The do while(0) construct is the only C syntax which expands correctly from C macros regardless of the use of curly braces and semicolons around the given macro.&lt;br /&gt;
&lt;br /&gt;
*  https://hownot2code.wordpress.com/2016/12/05/do-while-0-in-macros/&lt;br /&gt;
&lt;br /&gt;
=== [[#top|^]] stringification macro pair ===&lt;br /&gt;
&lt;br /&gt;
A useful macro pair, and this must be a macro pair, is the following set of defines.  These defines will accept a string and put double quotes around it:&lt;br /&gt;
&lt;br /&gt;
   #define TO_QUOTE_STRING(string) #string&lt;br /&gt;
   #define WRAPPER_TO_QUOTE_STRING(token) TO_QUOTE_STRING(string)&lt;br /&gt;
&lt;br /&gt;
Guy Rutenberg explains this C pre-processor pattern:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
*  https://www.guyrutenberg.com/2008/12/20/expanding-macros-into-string-constants-in-c/&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The core rule at play is that C preprocessor does not expand macros preceded by the `#` preprocessor directive, the directive to quote a token.  By creating a wrapping macro which does not call the `#` directive, the argument to the wrapper is expanded and then passed to the quoting directive.&lt;br /&gt;
&lt;br /&gt;
=== [[#top|^]] fallthrough macro ===&lt;br /&gt;
&lt;br /&gt;
The `__fallthrough()` macro appears to be a C++ macro.  It may be found among Zephyr RTOS 3.4.0 source tree contents.  An article on the concept of &amp;quot;fall through&amp;quot; in C switch statements:&lt;br /&gt;
&lt;br /&gt;
*  https://www.quora.com/What-is-the-fall-through-behavior-in-C-programming-languages-switch-case-statements&lt;br /&gt;
&lt;br /&gt;
=== [[#top|^]] X macro idiom ===&lt;br /&gt;
&lt;br /&gt;
X macros in C, a pattern involving nested macros makes use of nesting an initially declared and not defined macro within another macro.  Danilafe and Phillip Trudeau offer the following blog posts on this topic:&lt;br /&gt;
&lt;br /&gt;
*  https://danilafe.com/blog/chapel_x_macros/&lt;br /&gt;
* https://philliptrudeau.com/blog/x-macro&lt;br /&gt;
&lt;br /&gt;
Macro tips and idioms:&lt;br /&gt;
&lt;br /&gt;
*  https://github.com/pfultz2/Cloak/wiki/C-Preprocessor-tricks,-tips,-and-idioms&lt;br /&gt;
&lt;br /&gt;
=== [[#top|^]] FOREACH macro implementations (may not be fully possible) ===&lt;br /&gt;
&lt;br /&gt;
*  https://dev.to/sgf4/foreach-macro-in-c-48ic&lt;br /&gt;
&lt;br /&gt;
*  https://dev.to/sgf4/repeat-macro-in-c-2hh0&lt;br /&gt;
&lt;br /&gt;
Macro examples from Zephyr RTOS release 3.7.1:&lt;br /&gt;
&lt;br /&gt;
```&lt;br /&gt;
./include/zephyr/devicetree.h:4527:#define DT_INST_FOREACH_STATUS_OKAY(fn) \&lt;br /&gt;
./include/zephyr/devicetree.h:4544:#define DT_INST_FOREACH_STATUS_OKAY_VARGS(fn, ...) \&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
=== [[#top|^]] CONTAINER_OF macro ===&lt;br /&gt;
&lt;br /&gt;
Helpful blogpost by Radek Pazdera, full-stack software engineer based in London . . .&lt;br /&gt;
&lt;br /&gt;
* https://radek.io/posts/magical-container_of-macro/&lt;br /&gt;
&lt;br /&gt;
See also 2026 Q1 local page on [[developers|developers]].&lt;br /&gt;
&lt;br /&gt;
=== [[#top|^]] To use GCC to see macro expansion ===&lt;br /&gt;
&lt;br /&gt;
Here is an example shell script which invokes gcc on a single C source file, and causes only the preprocessor to execute.  This results in a display of all preprocessor macros:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# References:&lt;br /&gt;
#   * https://gcc.gnu.org/onlinedocs/gcc-3.2.2/cpp/Search-Path.html&lt;br /&gt;
&lt;br /&gt;
# $workspace/zephyr/subsys/testsuite/include/zephyr/fff.h&lt;br /&gt;
&lt;br /&gt;
gcc -E \&lt;br /&gt;
-I../../../../../zephyr/subsys/testsuite/include \&lt;br /&gt;
-I../../../../../zephyr/include \&lt;br /&gt;
./unit-test-mocked-functions.h&lt;br /&gt;
&lt;br /&gt;
exit $?&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- odne komentar --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ted</name></author>
	</entry>
</feed>