XCode 4.2编译器错误 [英] XCode 4.2 Compiler Error

查看:96
本文介绍了XCode 4.2编译器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用XCode 4.2(例如,Single View iOS App)创建新项目时,支持文件"-文件夹中的main.m文件看起来像:

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;
}

编译器设置(在构建设置"中)是Apple 3.0 LLVM.当我将其更改为GCC 4.2或GCC4.2 LLVM时,main.m显示错误.

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.

没有@autoreleasepool ...

在我的Xcode中进行哪些设置会导致此类问题?为什么新项目的标准编译器是Apple 3.0LLVM而不是系统默认的编译器(GCC4.2)?

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)??

推荐答案

要回答第一个问题:

在我的Xcode中进行哪些设置会引起此类麻烦?

Which Setting in my Xcode can cause such troubles?

设置本身就是编译器.将其更改为LLVM 3.0,不再麻烦

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

要回答第二个问题:

为什么新项目的标准编译器是Apple 3.0LLVM而不是系统默认编译器(GCC4.2)?

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

LLVM 3.0 IS 是Xcode 4.2的系统默认编译器.

LLVM 3.0 IS the system default compiler for Xcode 4.2.

我想您实际上是在问什么是不使用LLVM 3.0时如何解决该错误.为此,您需要像这样将@autoreleasepool替换为NSAutoreleasePool:

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;
}

这篇关于XCode 4.2编译器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆