-->

What is (double (^)(int))foofoo

2019-02-22 06:47发布

问题:

There is an example on cdecl that goes (double (^)(int))foofoo means cast foofoo into block (int) returning double.

What does it mean to cast foofoo into a "block" of int? What does the symbol ^ exactly mean in this context. Usually it is bitwise XOR.

回答1:

It's a GCC extension made by Apple, and implemented also in Clang. Blocks are small unnamed functions and that syntax is the type of a block. See Block Language Spec.