<?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>Software Warlock &#187; conditional compilation</title>
	<atom:link href="http://softwareblog.morlok.net/tag/conditional-compilation/feed/" rel="self" type="application/rss+xml" />
	<link>http://softwareblog.morlok.net</link>
	<description></description>
	<lastBuildDate>Sat, 24 Dec 2011 16:06:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Conditional Compilation for iPhone</title>
		<link>http://softwareblog.morlok.net/2009/06/17/conditional-compilation-for-iphone/</link>
		<comments>http://softwareblog.morlok.net/2009/06/17/conditional-compilation-for-iphone/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 04:31:52 +0000</pubDate>
		<dc:creator>Warlock</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[conditional compilation]]></category>

		<guid isPermaLink="false">http://softwareblog.morlok.net/?p=278</guid>
		<description><![CDATA[I&#8217;m working on a view right now that I want to be able to cross compile as either an NSView for the Mac, or a UIVIew for the iPhone. I originally wrote it for Leopard, but now I&#8217;m trying to &#8230;<p class="read-more"><a href="http://softwareblog.morlok.net/2009/06/17/conditional-compilation-for-iphone/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a view right now that I want to be able to cross compile as either an NSView for the Mac, or a UIVIew for the iPhone.  I originally wrote it for Leopard, but now I&#8217;m trying to add the precompiler directives to let it cross compile between the two platforms.  A quick Google search didn&#8217;t reveal anything, here are the possible definitions you can use:</p>
<pre name="code" class="c">
#define __MAC_10_0      1000
#define __MAC_10_1      1010
#define __MAC_10_2      1020
#define __MAC_10_3      1030
#define __MAC_10_4      1040
#define __MAC_10_5      1050
#define __MAC_10_6      1060
#define __MAC_NA        9999   /* not available */

#define __IPHONE_2_0     20000
#define __IPHONE_2_1     20100
#define __IPHONE_2_2     20200
#define __IPHONE_3_0     30000
#define __IPHONE_NA      99999  /* not available */
</pre>
<p>This definition comes from Availability.h located at <tt>/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include/Availability.h</tt> (for the iPhone 3.0 SDK).</p>
<p>Obviously, the <tt>__MAC_10_x</tt> is actually for the version of OSX, and the <tt>__IPHONE_x_x</tt> is for iPhone.</p>
<p>So, if you wanted to have code conditionally compile for the iPhone (assuming 3.0 SDK) you would do something like the following:</p>
<pre name="code" class="c">
#ifdef __IPHONE_3_0
    // iPhone
    #import &lt;UIKit/UIKit.h&gt;
#else
    // Mac
    #import &lt;Cocoa/Cocoa.h&gt;
#endif
</pre>
]]></content:encoded>
			<wfw:commentRss>http://softwareblog.morlok.net/2009/06/17/conditional-compilation-for-iphone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

