 
    
<?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>error Archives - Complete, Concrete, Concise</title>
	<atom:link href="https://complete-concrete-concise.com/tag/error/feed/" rel="self" type="application/rss+xml" />
	<link>https://complete-concrete-concise.com/tag/error/</link>
	<description>Practical Information Without The Bloat</description>
	<lastBuildDate>Tue, 19 Mar 2013 08:38:42 +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>Programming Error &#8211; Unintended String Concatenation</title>
		<link>https://complete-concrete-concise.com/programming/c/programming-error-unintended-string-concatenation/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Tue, 19 Mar 2013 08:38:42 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[comma]]></category>
		<category><![CDATA[concatenation]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[missing]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<guid isPermaLink="false">http://complete-concrete-concise.com/?p=2699</guid>

					<description><![CDATA[<p>In an effort to be helpful, C and C++ compilers concatenate adjacent strings together. In the following example, the compiler will concatenate the two strings into a single string: printf("This is a string " "and this is another string."); Which is probably what you intended anyway. Because C and C++ are free form languages, adjacent [&#8230;]</p>
<p>The post <a href="https://complete-concrete-concise.com/programming/c/programming-error-unintended-string-concatenation/">Programming Error &#8211; Unintended String Concatenation</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In an effort to be helpful, C and C++ compilers concatenate adjacent strings together.</p>
<p>In the following example, the compiler will concatenate the two strings into a single string:</p>
<pre><code>printf("This is a string " "and this is another string.");</code></pre>
<p>Which is probably what you intended anyway.</p>
<p>Because C and C++ are free form languages, adjacent strings can appear in many different formats &#8211; as this string table shows:</p>
<pre><code>char *array[] = {
    "str_1",
    "str_2",
    "str_3"
    "str_4",
    "str_5",
    NULL};</code></pre>
<p>Did you notice the missing comma (,) after <code>"str_3"</code>? It can be a hard one to spot.</p>
<p>This is the type of bug that can result in something like a simple parser failing:</p>
<pre><code>if (strcmp(array[i], test_string) == 0)</code></pre>
<p>because <code>str_3</code> and <code>str_4</code> will never be matched, but the others will.</p>

<p>The post <a href="https://complete-concrete-concise.com/programming/c/programming-error-unintended-string-concatenation/">Programming Error &#8211; Unintended String Concatenation</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WordPress &#8211; All Your Content has Vanished / Error 404 on All Pages</title>
		<link>https://complete-concrete-concise.com/wordpress-2/wordpress-all-your-content-has-vanished-error-404-on-all-pages/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Wed, 13 Mar 2013 17:51:06 +0000</pubDate>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[disappeared]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[gone]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[lose]]></category>
		<category><![CDATA[lost]]></category>
		<category><![CDATA[no comments]]></category>
		<category><![CDATA[no content]]></category>
		<category><![CDATA[vanished]]></category>
		<category><![CDATA[wordpress]]></category>
		<guid isPermaLink="false">http://complete-concrete-concise.com/?p=2676</guid>

					<description><![CDATA[<p>These instructions are for WordPress 3.X that is being hosted on a web server that provides access via cPanel version 11.34.1. The instructions may be the same or similar for other version combinations or interfaces other than cPanel, but no guarantees are made. Possible Symptoms You may encounter one or more of the following symptoms: [&#8230;]</p>
<p>The post <a href="https://complete-concrete-concise.com/wordpress-2/wordpress-all-your-content-has-vanished-error-404-on-all-pages/">WordPress &#8211; All Your Content has Vanished / Error 404 on All Pages</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="c1">
<p>These instructions are for WordPress 3.X that is being hosted on a web server that provides access via cPanel version 11.34.1.</p>
<p>The instructions may be the same or similar for other version combinations or interfaces other than cPanel, but no guarantees are made.</p>
</div>
<h1>Possible Symptoms</h1>
<p>You may encounter one or more of the following symptoms:</p>
<ul>
<li>All content and comments on your WordPress site have vanished:<br />
<a href="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-1-big.png" target="_blank"><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-1-thumb.png" alt="" border="0" class="centered"/></a></li>
<li>All content and comments show as having vanished in the dashboard:<br />
<img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-2.png" alt="" border="0" class="centered"/></p>
<li>Trying to go to a particular page (that you know exists) results in an <u>Http 404 Not Found message</u>:
<p><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2011/12/WordPress-error-404-not-found-login.png" alt="" border="0" class = "centered"/></p>
</li>
<li>You get a database connection error message:<br />
<a href="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-3-big.png" target="_blank"><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-3-thumb.png" alt="" border="0" class="centered"/></a></li>
</ul>
<h1>Possible Cause &#8211; Corrupted Database</h1>
<p>While it is possible that you have been hacked, it is far more likely that your WordPress database has become corrupted and is no longer able to serve up content.</p>
<p>I am not sure why this happens, but between November-2012 and March-2013 this has happened four times to me.</p>
<h1>Fixing the Problem</h1>
<p>There are two ways to fix this problem: (1) restore the database from a backup copy (preferred), (2) fix the database (only if you don&#8217;t have a backup).</p>
<h2>Checking if the Database is Corrupted</h2>
<p>Before doing anything rash, it is always best to check that a corrupt database is the problem.</p>
<p><strong>1) Log into</strong> your web hosting account (this is not your WordPress powered website). If you web host provides a cPanel interface, it might look something like this:</p>
<p><a href="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-9-big.png" target="_blank"><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-9-small.png" alt="" border="0" class="centered"/></a></p>
<p><strong>2) Click</strong> on <u>MySQL&reg; Databases</u>:</p>
<p><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-4.png" alt="" border="0" class="centered"/></p>
<p><strong>3) Locate</strong> the section titled <u>Modify Databases</u>. <strong>Select</strong> your database in the <u>Check DB</u> listbox and <strong>click</strong> on the <u>Check DB</u> button:</p>
<p><a href="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-5-big.png" target="_blank"><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-5-thumb.png" alt="" border="0" class="centered"/></a></p>
<div class="c1">
<p>How the databases are named, may depend on your service provider. If you have only one website and one database, then finding the correct one is easy.</p>
<p>If you have multiple websites or databases, then you my need to determine which database is which. In my case, I have WordPress and Joomla databases which can be identified by the suffix.</p>
</div>
<p><strong>4) Verify</strong> whether the database has errors or not. If the database comes up without <u>warnings</u> or <u>errors</u> then you have a different problem that will not be fixed by this tutorial. If it does have warnings or errors, then the steps in this tutorial may help:</p>
<p><a href="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-7-big.png" target="_blank"><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-7-thumb.png" alt="" border="0" class="centered"/></a></p>
<h2>Fixing the Database</h2>
<div class="c1">
<p>This is not the preferred method, but it is likely that most users do not have an up to date backup copy of their database.</p>
<p>If you do have an up to date backup copy of your database, then proceed to the next section.</p>
</div>
<p><strong>1) Click</strong> on <u>MySQL&reg; Databases</u>:</p>
<p><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-4.png" alt="" border="0" class="centered"/></p>
<p><strong>2) Locate</strong> the section titled <u>Modify Databases</u>. <strong>Select</strong> your database in the <u>Repair  DB</u> listbox and <strong>click</strong> on the <u>Repair DB</u> button:</p>
<p><a href="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-6-big.png" target="_blank"><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-6-thumb.png" alt="" border="0" class="centered"/></a></p>
<div class="c1">
<p>How the databases are named, may depend on your service provider. If you have only one website and one database, then finding the correct one is easy.</p>
<p>If you have multiple websites or databases, then you my need to determine which database is which. In my case, I have WordPress and Joomla databases which can be identified by the suffix.</p>
</div>
<p>As the database is being repaired, confirm that there are no errors. If there are errors, then run the <u>Repair DB</u> again (I have had to run it up to two times to repair a database):</p>
<p><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-8.png" alt="" border="0" class="centered"/></p>
<div class="c1">
<p>After this is done, I strongly recommend verifying that all your content is present and intact.</p>
<p>While I have not had a problem with this method, I can see cases where the database is not correctly repaired and content gets lost or is corrupted.</p>
</div>
<h2>Restoring the Database from a Backup</h2>
<div class="c1">
<p>This is the preferred method and presumes you have an up to date backup of your database.</p>
</div>
<p><strong>1) Click</strong> on <u>Backups</u>:</p>
<p><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-los-post-10.png" alt="" border="0" class="centered"/></p>
<p><strong>2) Locate</strong> the section called <u>Restore a MySQL Database</u> and <strong>click</strong> on <u>Browse&#8230;</u> and <strong>select</strong> the backup database from your computer. <strong>Click</strong> to upload the database.</p>
<p><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-los-post-11.png" alt="" border="0" class="centered"/></p>
<p>During this process, not much may seem to be happening.</p>
<p>The backup database has to be uploaded from your system to your service provider.</p>
<p>Once it is uploaded to the service provider, the existing database is <u>rebuilt</u> from the uploaded one.</p>
<p>The whole process looks something like this:</p>
<p><a href="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-11-big.png" target="_blank"><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2013/03/wp-lose-post-11-thumb.png" alt="" border="0" class="centered"/></a></p>
<div class="c4">
<p><strong>Note:</strong> Having up to date backups of your website and associated files is essential to being able to correct any problems that occur.</p>
<p>Hopefully, we never have to use it.</p>
</div>

<p>The post <a href="https://complete-concrete-concise.com/wordpress-2/wordpress-all-your-content-has-vanished-error-404-on-all-pages/">WordPress &#8211; All Your Content has Vanished / Error 404 on All Pages</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>w.bloggar &#8211; How to Fix &#034;Unable to parse the XML response&#034; Error</title>
		<link>https://complete-concrete-concise.com/blog/w-bloggar-how-to-fix-unable-to-parse-the-xml-response-error/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Sun, 08 Apr 2012 22:58:23 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[response]]></category>
		<category><![CDATA[w.bloggar]]></category>
		<category><![CDATA[xml]]></category>
		<guid isPermaLink="false">http://complete-concrete-concise.com/?p=1665</guid>

					<description><![CDATA[<p>I am probably one of the few, if only people around who use w.bloggar for my blogging needs. While it is an old and outdated program, it has three essential features for me: (1) customizable edit keys (that&#8217;s how I input these coloured sections without typing in HTML code), (2) it is easy to upload [&#8230;]</p>
<p>The post <a href="https://complete-concrete-concise.com/blog/w-bloggar-how-to-fix-unable-to-parse-the-xml-response-error/">w.bloggar &#8211; How to Fix &quot;Unable to parse the XML response&quot; Error</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="c1">
<p>I am probably one of the few, if only people around who use w.bloggar for my blogging needs. While it is an old and outdated program, it has three essential features for me: (1) customizable edit keys (that&#8217;s how I input these coloured sections without typing in HTML code), (2) it is easy to upload images and (3) it doesn&#8217;t add bloat to the images (the images I upload are in no way, shape, or form modified by w.bloggar).</p>
<p>For most people, though, I would still recommend Windows Live Writer.</p>
</div>
<p>A few days ago, I began having problems with w.bloggar when trying to post or upload images. It would return the message: &#8220;Unable to parse the XML response.Parser Reason:Invalid at the top level&#8221;:</p>
<p><img decoding="async" src="//complete-concrete-concise.com/wp-content/uploads/2012/04/w.bloggar-unable-to-parse-the-xml-response.png" alt="" border="0" class="centered" /></p>
<p>At first, I thought it was something funny happening at the server end of this site. I figured it would go away in a few hours. It didn&#8217;t.</p>
<p>Then I tried using Windows Live Writer. It worked.</p>
<p>Then I created a new account in w.bloggar through <u>File -> Add Account&#8230;</u>. This solved the problem.</p>
<p>For some reason, my original blog account info / setup / configuration has gone wonky. Creating a new account clears up the problem. (Of course, I still have the bother of recustomizing w.bloggar to my tastes again)</p>

<p>The post <a href="https://complete-concrete-concise.com/blog/w-bloggar-how-to-fix-unable-to-parse-the-xml-response-error/">w.bloggar &#8211; How to Fix &quot;Unable to parse the XML response&quot; Error</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Preprocessor &#8211; the #error Directive</title>
		<link>https://complete-concrete-concise.com/programming/c/preprocessor-the-error-directive/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Wed, 20 Jul 2011 08:04:02 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[preprocessor]]></category>
		<category><![CDATA[understanding]]></category>
		<guid isPermaLink="false">http://complete-concrete-concise.com/programming/c/927</guid>

					<description><![CDATA[<p>Preprocessor &#8211; the #error Directive This is a very useful and often underused preprocessor directive. Behaviour of this preprocessor directive is the same for both C and C++ compilers. Purpose The #error directive terminates compilation and outputs the text following the directive. Format #error text All preprocessor directives begin with the # symbol. It must [&#8230;]</p>
<p>The post <a href="https://complete-concrete-concise.com/programming/c/preprocessor-the-error-directive/">Preprocessor &#8211; the #error Directive</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Preprocessor &#8211; the #error Directive</p>
<div class="c1">
<p>This is a very useful and often underused preprocessor directive.</p>
<p>Behaviour of this preprocessor directive is the same for both C and C++ compilers.</p>
</div>
<h1>Purpose</h1>
<p>The <code>#error</code> directive terminates compilation and outputs the text following the directive.</p>
<h1>Format </h1>
<pre><strong>#error</strong> <em>text</em></pre>
<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>error</code>, but not escape characters or other symbols or macros. The preprocessor removes white space and concatenates the <code>#</code> and <code>error</code> together.</p>
<p>If anything follows the <code>#error</code> directive (other than white space) then the program is malformed.</p>
<p>The following are valid uses:</p>
<pre>#error some error message text
# error some error text to display
# /* comments are white space */ error some error message to display</pre>
<p>The following are invalid uses:</p>
<pre>// #\ is not a valid preprocessor directive
# \t error text to output
// #" is not a valid preprocessor directive
# "" text to output</pre>
<h1>Use</h1>
<p>It is used to render a program malformed and output the text following the <code>#error</code> directive. The text may be quoted or unquoted (it doesn&#8217;t matter). No macro expansion takes place.</p>
<div class="c2">
<p>The language specifications do not say how the text following the <code>#error</code> directive is to be treated.</p>
<p>The GCC compiler, replaces all white space characters between tokens with a single white space character.</p>
<p>I have no reason to believe other compilers behave differently since white space is not considered significant in the C and C++ languages &#8211; it serves only to seperate tokens from one another.</p>
</div>
<p>There are many times when it is useful to halt compilation:</p>
<ol>
<li>code is incomplete</li>
<li>code requires particular library versions</li>
<li>code uses compiler dependent features</li>
<li>code has specific compiler requirements</li>
</ol>
<h2>Incomplete Code</h2>
<p>When developing code, it is common to create stub functions. For the final release, these stub functions need to be implemented. We can let the compiler help us catch unimplemented functions:</p>
<pre><p>int my_function( void )</p>
<p>{</p>
<p> #error my_function not implemented</p>
<p> return 0;</p>
<p>}</p></pre>
<p>The above code will fail for every compile. It might be more useful to allow compiling during development, but break the compile when we try to compile a release version. In the following example, we assume that during development, the macro <code>DEBUG</code> is defined:</p>
<pre><p>int my_function( void )</p>
<p>{</p>
<p>#ifndef DEBUG</p>
<p> #error my_function not implemented</p>
<p>#endif
<p> return 0;</p>
<p>}</p></pre>
<p>During development, we can compile the code, but when we do a release build (one in which <code>DEBUG</code> is not defined, then we catch unimplemented functions.</p>
<h2>Version Checking</h2>
<p>Sometimes code is dependent on particular versions of a library. It is useful to be able to stop compilation if an incorrect library version is included:</p>
<pre><p>#if library_version < 2</p>
<p>#error requires library_version 2 or better</p>
<p>#endif</p></pre>
<h2>Compiler Dependency</h2>
<p>Sometimes, code uses compiler specific features (for example, GCC allows nesting a <code>#define</code> within another <code>#define</code> &#8211; this is a non-standard compiler feature).</p>
<pre>#ifdef __GCC__
<p>// some GCC specific code goes here</p>
<p>#else</p>
<p>#error requires GCC compiler to compile</p>
<p>#endif</p></pre>
<h2>Compiler Requirements</h2>
<p>Sometimes code makes relies on certain assumptions about the target environment (for example, the size of an integer):</p>
<pre><p>#include <limits.h></p>
<p>#if UINT_MAX != 4294967295</p>
<p> #error this application requires 32 bit integers</p>
<p>#endif</p></pre>

<p>The post <a href="https://complete-concrete-concise.com/programming/c/preprocessor-the-error-directive/">Preprocessor &#8211; the #error Directive</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilation Error &#8211; Improperly Defined Macro</title>
		<link>https://complete-concrete-concise.com/programming/c/compilation-error-improperly-defined-macro/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Wed, 08 Jun 2011 04:57:19 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[compile error]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[macro]]></category>
		<guid isPermaLink="false">http://complete-concrete-concise.com/programming/c/compilation-error-improperly-defined-macro</guid>

					<description><![CDATA[<p>Macros are tricky things to use in C/C++ programming. When they work, they work great. When they have bugs, they are a pain to troubleshoot. Macros are a simple text substitution done by the preprocessor. Whenever the macro name is encountered in your code, the preprocessor replaces it with the text to the right of [&#8230;]</p>
<p>The post <a href="https://complete-concrete-concise.com/programming/c/compilation-error-improperly-defined-macro/">Compilation Error &#8211; Improperly Defined Macro</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Macros are tricky things to use in C/C++ programming. When they work, they work great. When they have bugs, they are a pain to troubleshoot.</p>
<p>Macros are a simple text substitution done by the preprocessor. Whenever the macro name is encountered in your code, the preprocessor replaces it with the text to the right of the macro name (plugging in any optional parameters you may have passed).</p>
<p>A macro is composed of three parts:</p>
<ol>
<li><strong>#define</strong> &#8211; this introduces the macro</li>
<li><strong>macro name</strong> and optional parameter list. The macro name cannot have any spaces and the parameter list cannot be separated from the macro name with any spaces.</li>
<li><strong>text that will replace the macro</strong> &#8211; everything following the macro name (and optional parameter list), until the end of the line, is what the preprocessor will use to replace the macro name. For long macros, or for better formatting, the macro can be defined over several lines by ending each line with a backslash character  (\) and a new line (enter) (extra spaces between the backslash character and new line means the macro ends there &#8211; so be careful of extra spaces following the backslash).</li>
</ol>
<h1>Working Examples:</h1>
<p><code></p>
<pre>#define my_macro // preprocessor will replace my_macro with this comment.</pre>
<p></code><br />
<code></p>
<pre>#define my_macro // when the preprocessor encounters my_macro, \
                    it will replace it with everything on this \
                    line that is to the right of the definition \
                    (which is this comment). Fortunately, \
                    it is possible to spread the line over several \
                    lines by using the backslash character</pre>
<p></code></p>
<h1>Not Working Examples:</h1>
<p>The following macro won&#8217;t compile following expansion (it is supposed to replace the macro with the contents of the parameter list):</p>
<div class="c2"><code>#define my_macro (x) x</code><br />
<code>my_macro(int a);</code></div>
<p>The (unhelpful but correct) error message from the compiler (GCC v.4.4.1) is:</p>
<div class="c4"><code>error: expected '=', ',', ';', 'asm' or '__attribute__' before 'x'</code></div>
<p>The problem is the space between the macro name and the parameter list &#8211; there should be none.</p>
<p>Here&#8217;s another macro that won&#8217;t compile (like the one above, it is supposed to replace the macro with the parameters passed) :</p>
<div class="c2"><code>#define my_macro (x, y) x y</code><br />
<code>my_macro(int, abc);</code></div>
<p>The (unhelpful but correct) from the compiler (GCC v.4.4.1) is:</p>
<div class="c4"><code>error: expected ')' before ',' token</code></div>
<p>Again, the problem is a space between the macro name and the parameter list. Removing the space fixes the problem.</p>
<div class="c1">
<p>It is an <strong>error</strong> to separate the macro name and the macro parameter list with a space.</p>
</div>

<p>The post <a href="https://complete-concrete-concise.com/programming/c/compilation-error-improperly-defined-macro/">Compilation Error &#8211; Improperly Defined Macro</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Programming Error &#8211; Incorrect Array Declaration</title>
		<link>https://complete-concrete-concise.com/programming/c-programming/programming-error-incorrect-array-declaration/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Tue, 07 Jun 2011 19:23:19 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[corrupt]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[random]]></category>
		<guid isPermaLink="false">http://complete-concrete-concise.com/programming/c-programming/programming-error-incorrect-array-declaration</guid>

					<description><![CDATA[<p>In C++, we can declare an array by using the new operator: char *p = new char[50]; // dynamically allocate an array of 50 char This is useful in functions when we don&#8217;t know in advance how large the array should be or if we want to allocate the array in the heap instead of [&#8230;]</p>
<p>The post <a href="https://complete-concrete-concise.com/programming/c-programming/programming-error-incorrect-array-declaration/">Programming Error &#8211; Incorrect Array Declaration</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In C++, we can declare an array by using the <code><strong>new</strong></code> operator:</p>
<div class="c2"><code>char *p = new char[50]; // dynamically allocate an array of 50 char</code></div>
<p>This is useful in functions when we don&#8217;t know in advance how large the array should be  or if we want to allocate the array in the heap instead of the stack (the equivalent in C would be to use malloc() or calloc() to allocate the array)</p>
<p>A common programming error (because it looks very similar and is perfectly valid) is to replace the [] with ().</p>
<div class="c2"><code>char *p = new char(50);</code></div>
<p>In this case, we have allocated a single char and initialized its value to 50 &#8211; which is not what was intended.</p>
<p>This leads to those hard to track down bugs of corrupted data and / or random crashes.</p>
<p><strong>NOTE:</strong> when freeing an array created with <code><strong>new</strong></code>, remember to call <strong><code>delete[]</code></strong> instead of <code><strong>delete</strong></code> to avoid memory leaks (and definitely never call <code><strong>free()</strong></code>)</p>

<p>The post <a href="https://complete-concrete-concise.com/programming/c-programming/programming-error-incorrect-array-declaration/">Programming Error &#8211; Incorrect Array Declaration</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
