[futurebasic] Re: [FB] [FBtoC]CocoaSuggestion

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2011 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Sat, 18 Jun 2011 10:42:58 +1200
I wrote:

> SVanVoorst wrote:
>> One of the problems that I see using FBtoC to compile straight obj-c code is the addition of 43 Legacy calls.  
> When I build a pure Obj-C program and test it with /Developer/Extras/LegacyAPISurvey/LegacyAPISurvey.py, there are only 4 legacy function calls.
> CarbonCore HighLevelCalls.o	1	1	_FSGetCatalogInfo
> HIServices Processes.o	1	1	_GetProcessBundleLocation
> HIToolbox Events.o	1	1	_QuitApplicationEventLoop
> QD Rects.o	1	1	_SetRect
> You seem to be getting 39 more than me. Have you turned off the 'Strip unused code' checkbox in FBtoC settings? If so, turn it on. Otherwise please give the steps to reproduce the number 43.
>> It is my understanding that it is possible to manually remove these calls in Xcode C source files generated by FBtoC.  Would it be possible to not place these Legacy calls into the C code in the first place?
> Perhaps, once we know how your extra 39 functions are getting included.

It turns out that the number of legacy function calls remaining in a pure Obj-C app built by FB5 depends on the choice of compiler.
Only clang is able to correctly strip all unused functions, leaving the four indicated above.
To remove them, follow the procedure below.

Robert P.

Step 1. Locate InitFBGlobals() in Headers/Subs Compiler.incl, modify it as shown, then save.

local fn InitFBGlobals


[...existing function body...]

#if 1 

end fn

Step 2. In the settings dialog for your pure Obj-C project, choose clang as the compiler.

Step 3. In the settings dialog, click Advanced... 
In 'More compiler options' put:

Step 4. Trash the project's build_temp folder. This should be done *every* time you change 'More compiler options'.

A pure Obj-C FB5 app built with clang should now contain no legacy function calls. You can even put 
in 'More compiler options' and build a 64-bit Cocoa app. The file command in Terminal.app gives proof, for example:

$ file DotView_noNIB.app/Contents/MacOS/DotView_noNIB 
DotView_noNIB.app/Contents/MacOS/DotView_noNIB: Mach-O 64-bit executable x86_64