 
    
<?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>#ifndef Archives - Complete, Concrete, Concise</title>
	<atom:link href="https://complete-concrete-concise.com/tag/ifndef/feed/" rel="self" type="application/rss+xml" />
	<link>https://complete-concrete-concise.com/tag/ifndef/</link>
	<description>Practical Information Without The Bloat</description>
	<lastBuildDate>Wed, 13 Jul 2011 08:36:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>Preprocessor &#8211; the #ifndef Directive</title>
		<link>https://complete-concrete-concise.com/programming/c/preprocessor-the-ifndef-directive/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Wed, 13 Jul 2011 08:36:18 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[#ifndef]]></category>
		<category><![CDATA[preprocessor]]></category>
		<category><![CDATA[understanding]]></category>
		<guid isPermaLink="false">http://complete-concrete-concise.com/?p=888</guid>

					<description><![CDATA[<p>Behaviour of the #ifndef directive is the same in both C and C++. Purpose The #ifndef directive is one of five preprocessor selection statements allowing selection of alternative sections of code for compilation. The other four selection statements are: #ifdef, #if, #elif, and #else. Format #ifndef macro name valid preprocessor or code statements #endif or [&#8230;]</p>
<p>The post <a href="https://complete-concrete-concise.com/programming/c/preprocessor-the-ifndef-directive/">Preprocessor &#8211; the #ifndef Directive</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="c1">
<p>Behaviour of the <code>#ifndef</code> directive is the same in both C and C++.</p>
</div>
<h1>Purpose</h1>
<p>The <code>#ifndef</code> directive is one of five preprocessor selection statements allowing selection of alternative sections of code for compilation. The other four selection statements are: <code>#ifdef</code>, <code>#if</code>, <code>#elif</code>, and <code>#else</code>.</p>
<h1>Format </h1>
<div class="c2">
<p><strong>#ifndef</strong> <em>macro name</em></p>
<p>valid preprocessor or code statements</p>
<p><strong>#endif</strong> or <strong>#elif</strong> or <strong>#else</strong></p>
</div>
<p>All preprocessor directives begin with the <code>#</code> symbol. It must be the first character on the line or the first character on the line following optional white space. </p>
<div class="c4">
<p>Some early compilers flagged an error if <code>#</code> was not the first character on the line.</p>
</div>
<p>Spaces or tabs are permitted between the <code>#</code> and <code>ifndef</code>, but not escape characters or other symbols or macros. The preprocessor removes white space and concatenates the <code>#</code> and <code>ifndef</code> together.</p>
<p>The following are valid uses:</p>
<pre>#ifndef my_macro
# ifndef my_macro;
# ifndef my_macro
# /* comments are white space */ ifndef my_macro</pre>
<p>The following are invalid uses:</p>
<pre>// #\ is not a valid preprocessor directive
# \t ifndef my_macro
// #" is not a valid preprocessor directive
# "" ifndef my_macro</pre>
<h1>Use</h1>
<p>If the macro name does not exist, then the statements following <code>#ifndef</code> until the end of the block (<code>#endif</code>, <code>#else</code> or <code>#elif</code>) are compiled.</p>
<p>If the macro name exists, then the statements following <code>#ifndef</code> until the end of the block (<code>#endif</code>, <code>#else</code> or <code>#elif</code>) are skipped (not compiled).</p>
<p>Since the code is conditionally compiled, it is possible the code never gets compiled and, as a consequence, any errors in it are never caught or noticed.</p>
<p>The simplest preprocessor selection block consists of just an <code>#ifndef</code> and a terminating <code>#endif</code> statement.</p>
<p>More complex selection blocks consist of an <code>#ifndef</code> followed by one or more <code>#elif</code> and / or a final <code>#else</code> statement.</p>
<p>Any valid preprocessor statements, including other <code>#ifndef</code> statements, may be part of the code in the selection block. There is no limit on the level of nesting of selection statements. </p>
<p>The following:</p>
<pre>#ifndef my_macro</pre>
<p>is equivalent to:</p>
<pre>#if !defined my_macro</pre>
<p>This directive is most commonly used to prevent multiple inclusion of header files:</p>
<pre>#ifndef my_header
#define my_header
.
.
.
// contents of the header file
.
.
.
#endif</pre>

<p>The post <a href="https://complete-concrete-concise.com/programming/c/preprocessor-the-ifndef-directive/">Preprocessor &#8211; the #ifndef Directive</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
