1

我试图编译这段代码:

// Frist program example 

#import Foundation/Foundation.h>

int main (int argc, const char * argv [])
{
  NSAutoreleasePool * pool - [[NSAutoreleasePool alloc] init];
  NSLog (@"Programming is fun!");

  [pool drain];
  return 0;
}     

但是当我输入文件名时,编译器会显示一条错误消息:

./prog1.m: line 1: //: 是一个目录
./prog1.m: line 6: 意外标记'('附近的语法错误
./prog1.m: line 6: 'int main (int argc, const char *argv [])'

4

1 回答 1

2

你有一个-你想要的地方=

尝试这个:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv [])
{
  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
  NSLog (@"Programming is fun!");

  [pool drain];
  return 0;
}     
于 2011-07-13T18:03:06.000 回答