Search code examples
objective-cxcode4

Parse and semantic issues compiling a simple hello world file


I use xcode 4, I already compiled Cocoa applictions without problems, but if I choose to compile a simple command line tool like this one:

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

int main (int argc, const char * argv[])
{
    printf("Hello world");
    return 0;
}

I get a lot of parse and sematic issues:

_Issues_

enter image description here

If this isn't enough I could take the screen of the whole window. So what could be the reason of these errors?


Solution

  • You named your main file as main.cpp. That's a C++ file. You then handed it Objective-C. Your main file should be main.m.