<?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>preprocessor &#8211; Luxing Huang</title>
	<atom:link href="https://luxing.im/tag/preprocessor/feed/" rel="self" type="application/rss+xml" />
	<link>https://luxing.im</link>
	<description>Thoughs and things</description>
	<lastBuildDate>Mon, 14 Oct 2013 00:57:30 +0000</lastBuildDate>
	<language>en-CA</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
<site xmlns="com-wordpress:feed-additions:1">58771605</site>	<item>
		<title>C Preprocessor check before compilation</title>
		<link>https://luxing.im/c-preprocessor-check-before-compilation/</link>
					<comments>https://luxing.im/c-preprocessor-check-before-compilation/#respond</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Mon, 14 Oct 2013 00:57:30 +0000</pubDate>
				<category><![CDATA[Learning Notes]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[preprocessor]]></category>
		<category><![CDATA[programming]]></category>
		<guid isPermaLink="false">http://blog.luxing.im/?p=122</guid>

					<description><![CDATA[In C, the #define token is widely used as a macro and maybe others. When we write a program with complex #define and such, maybe incorrectly used on top of another, how can we see if they are really correct? In GCC (and probably others like c++), we can use -E flag to show what &#8230; <p class="link-more"><a href="https://luxing.im/c-preprocessor-check-before-compilation/" class="more-link">Continue reading<span class="screen-reader-text"> "C Preprocessor check before compilation"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>In C, the <em>#define</em> token is widely used as a macro and maybe others. When we write a program with complex <em>#define</em> and such, maybe incorrectly used on top of another, how can we see if they are really correct?<br />
<span id="more-122"></span><br />
In GCC (and probably others like c++), we can use -E flag to show what the code will look like after the preprocessing part, but not yet compiled.</p>
<p>For example, we write a short test code here:</p>
<pre>
#include <stdio.h>

/* Looking for the minimum */
#define MIN(a, b) (a < b ? a : b)
int main(int argc, char *argv[])
{
    int a = 5;
    int b = 3;
    printf("%d\n", MIN(a, b));
    return 0;
}
</pre>
<p>With gcc -E now we see:</p>
<pre>
......
# 943 "/usr/include/stdio.h" 3 4

# 2 "arg.c" 2

int main(int argc, char *argv[])
{
    int a = 5;
    int b = 3;
    printf("%d\n", (a < b ? a : b));
    return 0;
}
</pre>
<p>Which is quite useful to see the validity of macro correctness.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/c-preprocessor-check-before-compilation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">122</post-id>	</item>
	</channel>
</rss>
