2 Replies Last post: Feb 26, 2013 9:50 PM by JP Bekmann  
JP Bekmann Newbie 2 posts since
Feb 15, 2013
Currently Being Moderated

Feb 15, 2013 1:43 AM

objC blocks vs C++11 lambda

Xcode allows the use of lambdas to be passed as objC blocks, so the following code compiles and works:

 

typedef void (^my_handler_t)(bool b);

static void myfunc(bool ok, my_handler_t handler) {

  handler(ok);

}

int main() {

    myfunc(true, [](bool v){ printf("%d", v); });

}

 

 

AppCode complains that the lambda expression is of type void (*)(bool b).  (i.e. this is fixed by changing the typedef to void (*my_handler_t)(bool b)). I have existing code that I can't change, and AppCode compiles fine with Clang from AppCode. Is there some way to disable these errors?

 

thanks,

JP

Anton Makeev JetBrains 1,083 posts since
Dec 19, 2006
Currently Being Moderated
Feb 26, 2013 4:31 PM in response to: JP Bekmann
Re: objC blocks vs C++11 lambda

Could you please file a bug report for the problem?

http://youtrack.jetbrains.com/issues/OC

More Like This

  • Retrieving data ...