views:

396

answers:

1

I'm trying to work through Apple's CoreData Utility Tutorial. It asks me to create a 'Foundation Tool' project in the 'Command Line Utility' section. In XCode 3.2, I only found a 'Command Line Tool' section with a 'Foundation' type in the 'New Project' wizard.

So I created the 'Command Line Tool' 'Foundation' type project, and added the following line to enable garbage collection:

objc_startCollectorThread();

I also changed the 'Objective-C Garbage Collection' setting in my 'Target Info' 'Build' tab to 'Required [-fobjc-gc-only]'. When I run my build, I get the following error:

warning: implicit declaration of function 'objc_startCollectorThread'

The target runs fine so far. All it does is print 'Hello World' to the console. I'm just concerned about this warning. I must be doing something wrong if I'm getting warnings for something as basic as garbage collection on a command line tool.

+10  A: 

You should #include <objc/objc-auto.h>, which is where this function is defined.

kperryua
Or **`#import`** instead. Either way, +1 for the good answer.
Quinn Taylor
I think the typical convention is to `#include` C headers (like this one) and `#import` Objective-C headers.
kperryua