<?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>coding &#187; linguagem c</title>
	<atom:link href="http://www.coding.com.br/tag/linguagem-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.coding.com.br</link>
	<description>have you coded today?</description>
	<lastBuildDate>Fri, 23 Jul 2010 02:37:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple C macro for debugging</title>
		<link>http://www.coding.com.br/programacao/simple-c-macro-for-debugging/</link>
		<comments>http://www.coding.com.br/programacao/simple-c-macro-for-debugging/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 03:30:18 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[programação]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[linguagem c]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=687</guid>
		<description><![CDATA[A little trick if you use printf to debug information in your code and don&#8217;t like to comment/uncomment.

#include &#60;stdio.h&#62;
&#160;
#define dprintf if (debug) printf
&#160;
const char debug = 1; /* or 0 if you want disable debug */ 
&#160;
int main&#40;int argc, char *argv&#91;&#93; &#41; &#123;
     dprintf &#40;&#34;debug message&#34;&#41;;
     return [...]]]></description>
			<content:encoded><![CDATA[<p>A little trick if you use <em>printf</em> to debug information in your code and don&#8217;t like to comment/uncomment.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #339933;">#define dprintf if (debug) printf</span>
&nbsp;
<span style="color: #993333;">const</span> <span style="color: #993333;">char</span> debug <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* or 0 if you want disable debug */</span> 
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     dprintf <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;debug message&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p align="justify">
Remember that using <em>printf</em> is just one way to debug your code and an excess can impair the efficiency to analyze the situation or catch bugs. If you need start your program, specifying anything that might affect its behavior; make your program stop on specified conditions; examine what has happened, when your program has stopped or change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another; use programs such as <a href="http://www.gnu.org/software/gdb/">GDB</a> or <a href="http://valgrind.org/">Valgrind</a> (especially to memory management issues)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/programacao/simple-c-macro-for-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
