0

This could sound a bit weird.

In main.m, it is written as such:

int main(int argc, char * argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([RTAppDelegate class]));
    }
}

which is a C-style main function (though with typical [class method] function call). But if we look at syntax of objective-C, one might think of something like this:

+(int)main:(int)argc :(char*) argv[] //I don't really know if (char*) argv[] will be legit in obj-c
{
        // DO SOMETHING
        return 0;
}

So I'm getting confused about the language itself. Does objective-c simply extends C-syntax? Or is it an independent language itself?

4

1 回答 1

3

Objective-C 是 C 的超集。因此,您可以(或至少应该能够)通过 Objective-C 编译器编译任何 C 程序。

知道这一点后,ANSI C 标准规定 main 的正确声明是int main(int argc, char** argv)or int main(void)

http://c-faq.com/ansi/maindecl.html

于 2013-11-14T20:06:38.373 回答