I am trying to learn and use Blocks effectively.
On the web, I have come across this code:
long long (^blockFun)() = (long long (^)())moreBlockFun;
I think it is trying to create a block that expects a block that returns a long and I think it is doing some casting somewhere too.
It’s a block type cast and yes, the syntax isn’t great. We assume that
moreBlockFunis a block that takes no parameters, and returns something with a sensible cast to long long – this type signature is writtenlong long (^)(). So we create a new local name for that block calledblockFun, with the syntaxlong long (^blockFun)(), and perform the cast.It’s a mess mostly inherited from function pointer type notation, which virtually every C programmer has to lookup around 482 times before they remember it. You’re not alone!