Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are two tools I know of that you could use to do this semi-automatically.</p> <p>One is <a href="https://sourceforge.net/projects/sunifdef/" rel="nofollow noreferrer"><code>sunifdef</code></a> (son of <code>unifdef</code>). AFAIK, this is no longer being maintained, though (and neither is <code>unifdef</code> on which it is based).</p> <p>The other is <a href="http://coan2.sourceforge.net/index.php" rel="nofollow noreferrer"><code>coan</code></a>, which is being actively maintained, and is a development of <code>sunifdef</code>.</p> <p>See also: <a href="https://stackoverflow.com/questions/525283/is-there-a-c-pre-processor-which-eliminates-ifdef-blocks-based-on-values-define">Is there a C pre-processor which eliminates <code>#ifdef</code> blocks based on values defined/undefined?</a>.</p> <p>As it happens, I'm still using <code>sunifdef</code> on the main project at work where I'm eliminating archaic code (for example, machines not supported since about 1996) from the code base. The only gotcha I have with it is that if a line goes in with parentheses like this:</p> <pre><code>#if (defined(MACH_A) &amp;&amp; defined(PROP_P)) || (defined(MACH_B) &amp;&amp; defined(PROP_Q)) || \ (defined(MACH_C) &amp;&amp; defined(PROP_R)) </code></pre> <p>and we have <code>-UMACH_C</code> (so machine C is no longer supported), the output line is:</p> <pre><code>#if defined(MACH_A) &amp;&amp; defined(PROP_P) || defined(MACH_B) &amp;&amp; defined(PROP_Q) </code></pre> <p>Technically, that's fine; it is correct. It is just preferable to keep the extra, technically redundant parentheses in the expression.</p> <p>One caveat: although I can answer for these compiling on Unix-based systems, I've not personally checked them out on Windows.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload