#import <Foundation/Foundation.h> considered incorrect


I found that the following program, based on the NSDate examples in chapter 12 to fails to compile with 3951 errors, using XCode 3.2.6:

#include <stdio.h>
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
// @autoreleasepool


return 0;


The problem seems to be that that the import statement is incorrect, should it not be:

[color=#40FF40]#import <CoreFoundation/CoreFoundation.h>[/color] ?


I suspect that the C compiler (not the ObjC compiler) is unhappy about this. Is the file a .m file or a .c file? (It should be a .m file)


I got it working, I had been selecting ‘core foundation’ instead of ‘foundation’ in the project setup wizard. Thanks.


Thank you. It works now.

I have been choosing Type “C” while creating a new project (after developing the C example in earlier chapter). This is wrong. :blush:
I chose Type “Foundation” and main.m. It works perfect now.