C "block" caret character
Asked Answered
E

2

10

I've noticed that this declaration involving a caret (^) character is pinned on the cdecl.org site at the top:

// "cast foo into block(int, long long) returning double"
(double (^)(int , long long ))foo

Can somebody explain what is the purpose of the caret character here? Is this really a valid character in C declarations, or is this a placeholder for something?

Ex answered 9/3, 2020 at 11:56 Comment(0)
A
6

The caret is part of an extension to the C language to work with blocks. Blocks are an extension to C supported by Clang and Apple’s GCC. It is not strictly conforming C (that is, not part of the core C language defined by the C standard).

Anstice answered 9/3, 2020 at 12:1 Comment(0)
F
4

It is known as Block Variable Declaration. A variable with Block type is declared using function pointer style notation substituting ^ for *.

Floodlight answered 9/3, 2020 at 12:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.