Thursday, 5 February 2009

Universal Binary

I just copied moneyLounge across to my old Mac G5 and, too my horror, discovered that it wouldn't even startup. I was getting the message "invalid architecture". Some hunting around on google quickly determined that I needed to compile a universal binary version of moneyLounge. This is done simple by changing the "Architectures" setting in the Build properties of the target. I'll guess this means I'll need two targets from now. All went well except for one interesting (and hard to track down) run error. This concerns the use of code such as:

int row;
if(row==NSNotFound) then ....

In the native architecture of my Intel Mac this code would work fine, but in the 32/64 bit Universal version it didn't. This was because NSNotFound is defined as the largest possible long datatype rather then integer. I guess this is the difference between the 32 and 64 bit versions. The upshot of this was that I recoded all my "int" datatypes to NSUInteger, making the code a lot more generic in any case. Something to bear in mind I guess - try and use the NS datatypes rather then the simple C versions.

No comments: