<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>His Deeds Are Dust &#187; C</title>
	<atom:link href="http://hisdeedsaredust.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://hisdeedsaredust.com</link>
	<description>surveying sub-optimal solutions</description>
	<lastBuildDate>Wed, 02 May 2012 13:16:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>The undervalued bool</title>
		<link>http://hisdeedsaredust.com/2010/06/the-undervalued-bool/</link>
		<comments>http://hisdeedsaredust.com/2010/06/the-undervalued-bool/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:43:04 +0000</pubDate>
		<dc:creator>Paul Flo Williams</dc:creator>
				<category><![CDATA[Poor choices]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://hisdeedsaredust.com/?p=155</guid>
		<description><![CDATA[A colleague of mine wanted to reduce the repetition in this fragment of C++: funcA(false); funcB(false); funcC(false); funcD(false); funcA(true); funcB(true); funcC(true); funcD(true); and, in a burst of sheer genius, came up with this solution: for (bool status = false; status]]></description>
			<content:encoded><![CDATA[<p>A colleague of mine wanted to reduce the repetition in this fragment of C++:</p>
<pre>
funcA(false);
funcB(false);
funcC(false);
funcD(false);
funcA(true);
funcB(true);
funcC(true);
funcD(true);
</pre>
<p>and, in a burst of sheer genius, came up with this solution:</p>
<pre>
for (bool status = false; status <= true; ++status) {
  funcA(status);
  funcB(status);
  funcC(status);
  funcD(status);
}
</pre>
<p>He then scratched his head as the program looped for eternity.</p>
<p>Who could have predicted that a common-or-garden <code>bool</code> could have so many values? Let me count them. The possible values of <code>bool</code> are <i>false</i>, <i><a href="http://www.snopes.com">snopes</a></i>, <i>statistically_significant</i>, <i>almost_true</i>, <i>true</i>, <i>very_true</i> and <i>tautology</i>. <code>++tautology</code> gives you <i>tautology</i> right back, as <a href="http://en.wikipedia.org/wiki/Nigel_Molesworth">any fule kno</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hisdeedsaredust.com/2010/06/the-undervalued-bool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The magic of #ifdef</title>
		<link>http://hisdeedsaredust.com/2009/12/the-magic-of-ifdef/</link>
		<comments>http://hisdeedsaredust.com/2009/12/the-magic-of-ifdef/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 10:10:27 +0000</pubDate>
		<dc:creator>Paul Flo Williams</dc:creator>
				<category><![CDATA[Poor choices]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://hisdeedsaredust.com/?p=117</guid>
		<description><![CDATA[The beauty of the preprocessor #ifdef . . . #endif directives in C and C++ is that there are so many ways to abuse them. I&#8217;ve been working on some vintage code (at least 15 years old) that provides a model for how not to do things. The compilation is controlled by no fewer than [...]]]></description>
			<content:encoded><![CDATA[<p>The beauty of the preprocessor <tt>#ifdef</tt> . . . <tt>#endif</tt> directives in C and C++ is that there are so many ways to abuse them.</p>
<p>I&#8217;ve been working on some vintage code (at least 15 years old) that provides a model for how not to do things. The compilation is controlled by no fewer than 750 <tt>#ifdef</tt> switches. Many of these are used in header files as guards against double inclusion, but the others roughly split into these jobs:</p>
<ul>
<li>controlling platform-specific code generation</li>
<li>controlling project-specific code generation</li>
<li>experimental features</li>
<li>controlling different versions of hardware</li>
</ul>
<p>The oddest of these switches are:
</p>
<p><i>For the people who don&#8217;t like to document</i>:
</p>
<pre>#ifdef __
</pre>
<p><i>For dyslexic programmers</i>:
</p>
<pre>#ifdef DSTL_UPGRADES
#ifdef DTSL_UPGRADES
</pre>
<p><i>For those who think the code runs too quickly</i>:
</p>
<pre>#ifdef INEFFICIENT
</pre>
<p><i>For those hopeful of a quick fix</i>:</p>
<pre>#ifdef MAKETHISWORK
</pre>
<p><i>For those who aren&#8217;t confident of our source control systems (and are dyslexic)</i>:</p>
<pre>#ifdef OLD_SLOW_WAY
#ifdef ORIGINAL_CODE
#ifdef OROGINAL_CODE
#ifdef REDUNDANT_CODE
#ifdef REDUNDANT_FUNCTIONS
</pre>
<p><i>For those who can&#8217;t quite remember which operating system they are using</i>:</p>
<pre>#ifdef _vxworks
#ifdef __vxworks
#ifdef VXWORKS
#ifdef _VXWORKS
#ifdef __VXWORKS
</pre>
<p><i>For those trying the super-secret go-faster-stripes</i>:</p>
<pre>#ifdef WIN32_LEAN_AND_MEAN
</pre>
<p><i>For those who super unpositively don&#8217;t no way double negative want that code</i>:</p>
<pre>#ifdef _WIN32_trynot
</pre>
<p><i>. . . but just the once, or later, or huh, maybe not at all?</i>:</p>
<pre>#ifdef __JUSTONCE__
#ifdef _JUST_ONCE_
#ifdef notdef
#ifdef __NOTSMART_
#ifdef _NOTSMART_
#ifdef notyet
#ifdef NOTYET
#ifdef THIS_IS_NECESSARY
#ifdef THIS_IS_TOO_EXPENSIVE
</pre>
<p>Even the choice of names for include guards shows how coding standards change over time, or are ignored, or how the language standards themselves are ignored (the leading underscores):</p>
<pre>xxx_inc_
_xxx_H_
__xxx_H__
xxx_include
xxx_H
xxx_inc
xxx_h
xxx_Hinc
_INC_xxx
INC_xxx
</pre>
]]></content:encoded>
			<wfw:commentRss>http://hisdeedsaredust.com/2009/12/the-magic-of-ifdef/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

