Start by eliminating the build warnings that your project currently generates; this will make it easier to focus on warnings that are specific to 64-bit conversion problems. Also save a copy of the project in case something goes wrong in the conversion process and you need to start over. Then in a Terminal shell run the tops conversion script Cocoa64.tops located in /Developer/Extras/64BitConversion/. You can run the script on specific source and header files, as in this example:
tops -semiverbose -scriptfile /Developer/Extras/64BitConversion/Cocoa64.tops Controller.h Controller.m CustomView.h CustomView.h |
Or you can run it on all .h and .m files in your project, as in this example:
tops -semiverbose -scriptfile /Developer/Extras/64BitConversion/Cocoa64.tops `find . -name '*.[hm]' | xargs` |
The -semiverbose option tells tops to show the progress of conversion for each file. For other options, check the tops man page.
As the script runs, it does the following things:
It converts most instances of int and unsigned int to NSInteger and NSUInteger, respectively. It doesn't convert ints in bit-field declarations and other inappropriate cases. During processing, the script refers to a hardcoded list of exceptions.
It converts most instances of float to CGFloat, again leaving untouched those exceptions specified in a hardcoded list.
It does not convert enum declarations to types with guaranteed fixed sizes (as described in “Enumeration Constants”). You need to fix these declarations by hand.
It flags (with inline warnings) cases that need to be fixed manually. See “Things to Look For During Conversion” for details.
After the script completes processing all files, run the FileMerge development application on each changed file and an unchanged version of the same file. FileMerge visually highlights each modified section of code. After reading “Things to Look For During Conversion,” evaluate each of these sections plus the warnings generated by the script and make further changes if necessary.
Remember that any 64-bit change you make should help preserve binary compatibility of your project executable on 32-bit systems. You should use the constructs in Table 3-1 to mark off sections of code conditionally for each architecture: PowerPC versus Intel and 32-bit versus 64-bit.
Macro | Comment |
|---|---|
| PowerPC or Intel 64-bit. You should use this for most 64-bit changes. |
| PowerPC 32-bit |
| PowerPC 64-bit |
| Intel 32-bit |
| Intel 64-bit |
| Big endian architectures |
Last updated: 2007-03-22