<?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>Orange Juice Liberation Front &#187; oserror</title>
	<atom:link href="http://orangejuiceliberationfront.com/tag/oserror/feed/" rel="self" type="application/rss+xml" />
	<link>http://orangejuiceliberationfront.com</link>
	<description>Uli&#039;s citrussy fresh thoughts on technical stuff</description>
	<lastBuildDate>Mon, 13 May 2013 20:59:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Carbon for the Cocoa Guy: OSError and OSStatus</title>
		<link>http://orangejuiceliberationfront.com/carbon-for-the-cocoa-guy-oserror-and-osstatus/</link>
		<comments>http://orangejuiceliberationfront.com/carbon-for-the-cocoa-guy-oserror-and-osstatus/#comments</comments>
		<pubDate>Wed, 31 Aug 2005 10:48:41 +0000</pubDate>
		<dc:creator>uliwitness</dc:creator>
				<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[carbon]]></category>
		<category><![CDATA[flatcarbon]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[macerrors]]></category>
		<category><![CDATA[oserror]]></category>
		<category><![CDATA[osstatus]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[umbrella headers]]></category>

		<guid isPermaLink="false">http://blog.orangejuiceliberationfront.com/?p=64</guid>
		<description><![CDATA[I recently posted a rather lengthy explanation of Carbon&#8217;s operating-system-error-code-based error-handling mechanism to Student-Dev, and thought those Cocoa programmers here who need to use Carbon calls for some things might be interested in this bit of explanation: There&#8217;s OSErr and OSStatus. What&#8217;s the difference? OSErr and OSStatus are effectively the same data type. OSErr is &#8230;  <a href="http://orangejuiceliberationfront.com/carbon-for-the-cocoa-guy-oserror-and-osstatus/">Continue reading</a>]]></description>
				<content:encoded><![CDATA[<p>I recently posted a rather lengthy explanation of Carbon&#8217;s operating-system-error-code-based error-handling mechanism to Student-Dev, and thought those Cocoa programmers here who need to use Carbon calls for some things might be interested in this bit of explanation:</p>
<h2>There&#8217;s OSErr and OSStatus. What&#8217;s the difference?</h2>
<p>OSErr and OSStatus are effectively the same data type. OSErr is the older of the two, and has been around since the early days (I&#8217;ve been using it since System 6, but it probably was around since 1.0 or so). An OSErr is a short int (2 bytes), and when Apple realized they&#8217;d be running out of error numbers (there are some reserved numbers in the OSErr range), they introduced OSStatus (sometime during the System 8 or 9 days), which is a long int (4 bytes) and should suffice for a while.</p>
<h2>What values can an OSStatus contain, and where can I find them?</h2>
<p>Most of the values for OSErr and OSStatus are defined in the <tt>MacErrors.h</tt> header. If, for you, this header simply includes <tt>CoreServices/CoreServices.h</tt>, you caught the MacErrors.h file in FlatCarbon. The one in FlatCarbon is simply for backwards compatibility. So, make sure you look for the header in <tt>/System/Library/Frameworks</tt></p>
<h2>FlatCarbon ?!</h2>
<p>In the old (pre-OS X) days, you&#8217;d explicitly include <tt>MacErrors.h</tt>. Since MacOS X we have <em>umbrella headers</em> in each framework that allow you to include one header and get all headers in that Framework. FlatCarbon is a hack to allow older code to be compiled without having to replace all those includes.</p>
<p>If you find a FlatCarbon header, you can fairly easily find the right header by just looking what framework it includes and digging in that framework&#8217;s headers and sub-frameworks. For example, FlatCarbon&#8217;s <tt>MacErrors.h</tt> header includes CoreServices, so check out <tt>/System/Library/Frameworks/CoreServices.framework</tt>&#8216;s umbrella header <tt>CoreServices.h</tt> in its <tt>Headers</tt> subfolder. It includes (among others) CarbonCore, so take a look at that framework. It&#8217;s a sub-framework of CoreServices, meaning you&#8217;ll find it in CoreServices&#8217; <tt>Frameworks</tt> subfolder. And, surprise, surprise, you&#8217;ll find the real <tt>MacErrors.h</tt> in CarbonCore&#8217;s <tt>Headers</tt> folder. It contains oodles of constants defining many possible values for OSStatus and OSErr.</p>
<h2>Help! MacErrors.h doesn&#8217;t list my error?!</h2>
<p>Some Carbon APIs also define some additional error constants in their own headers. So, you might get error codes not listed in <tt>MacErrors.h</tt>, in which case you&#8217;ll want to look up the header for the API call that returned that particular error and look there for a constant that names and explains that error code.</p>
<p>If you can&#8217;t find it there, there are some other ways to find the errors. For example, some CoreAudio developer didn&#8217;t understand that error codes are supposed to be numbers, and actually used a FourCharCode for some errors. So, if you get an insanely high or low number, try viewing it as four characters (also called an &#8216;OSType&#8217;) and search for that.</p>
<p>Also, IOKit has some errors that are actually assembled from bit fields and flags, in which case you&#8217;d best write a little app that dumps the numeric equivalents of IOKit&#8217;s error constants and compare those to your error number.</p>
<p>Oh, and BTW: The constant <tt>noErr</tt> (which evaluates to zero) indicates success.</p>
]]></content:encoded>
			<wfw:commentRss>http://orangejuiceliberationfront.com/carbon-for-the-cocoa-guy-oserror-and-osstatus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

 Served from: orangejuiceliberationfront.com @ 2013-05-23 23:59:19 by W3 Total Cache -->