2
votes

When I create a new Project with XCode 4.2 (a Single View iOS App, for instance) the main.m-File in the "Supporting Files"-Folder looks like:

#import <UIKit/UIKit.h>
#import "iiiAppDelegate.h"

int main(int argc, char *argv[])
{
    int retVal = 0;
    @autoreleasepool {
    retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([iiiAppDelegate class]));
    }

    return retVal;
}

The Compiler Setting (in Build Settings) is the Apple 3.0 LLVM. When I change it to GCC 4.2 or GCC4.2 LLVM it shown errors with the main.m.

There is no @autoreleasepool...

Which Setting in my Xcode can cause such troubles? Why is the standard compiler for new projects the Apple 3.0LLVM instead of the system default compiler (GCC4.2)??

2

2 Answers

6
votes

To answer your first question:

Which Setting in my Xcode can cause such troubles?

The compiler itself is the setting. Change it to LLVM 3.0 and no more troubles

To answer your second question:

Why is the standard compiler for new projects the Apple 3.0LLVM instead of the system default compiler (GCC4.2)??

LLVM 3.0 IS the system default compiler for Xcode 4.2.

I think what you are actually asking is how to fix the error when not using LLVM 3.0. To do that, you would want to replace @autoreleasepool with NSAutoreleasePool like so:

int main(int argc, char *argv[]) {
    int retVal = 0;

    // @autoreleasepool {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([iiiAppDelegate class]));

    [pool drain];
    // }

    return retVal;
}
3
votes

@autoreleasepool is a new feature added in LLVM 3.0. It just cannot work using the other compilers you tried.