Blocks (C language extension)

Language runtime library support for blocks is also available as part of the LLVM project.

[5] Like function definitions, blocks can take arguments, and declare their own variables internally.

A simple example capturing mutable state in the surrounding scope is an integer range iterator:[6] The blocks runtime is not part of the C library(s) linked by default on some systems.

[7] Blocks bear a superficial resemblance to GCC's extension of C to support lexically scoped nested functions.

[8] However, GCC's nested functions, unlike blocks, must not be called after the containing scope has exited, as that would result in undefined behavior.