黑马程序员技术交流社区

标题: 为什么会报错:expected identifier or '(' before '^' token? [打印本页]

作者: 瑾❤    时间: 2014-6-28 09:46
标题: 为什么会报错:expected identifier or '(' before '^' token?
本帖最后由 瑾❤ 于 2014-6-28 18:00 编辑
  1. #import <Foundation/Foundation.h>
  2. int main()
  3. {
  4.     int (^sumBlock)(int,int)=^(int a,int b)
  5.     {
  6.         return a+b;
  7.     };

  8.     int sum=sumBlock(1,2);
  9.     NSLog(@"sum=%d",sum);
  10.     return 0;
  11. }
复制代码

用codeBlock编译block代码的时候报错,但不知道原因出在哪里,各位帮帮忙啊{:2_31:}。。。

作者: ★Joean_Zhou    时间: 2014-6-28 11:12
为什么我的不报错呢?

作者: 骑着飞机去看海    时间: 2014-6-28 11:42
我的也木有。。。。。:L
作者: 瑾❤    时间: 2014-6-28 12:39
★Joean_Zhou 发表于 2014-6-28 11:12
为什么我的不报错呢?

是用codeBlock编译吗?
作者: ★Joean_Zhou    时间: 2014-6-28 14:13
瑾❤ 发表于 2014-6-28 12:39
是用codeBlock编译吗?

就是用的Xcode直接编译的呀
作者: 瑾❤    时间: 2014-6-28 17:59
★Joean_Zhou 发表于 2014-6-28 14:13
就是用的Xcode直接编译的呀

好吧,那我这个应该就是编译器的问题




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2