Tech News
← Home  ·  All topics

C Lambdas

1 GoKawiil brief on this topic

GCC's Nested Functions: How They Differ From C++ Lambdas Internally

Martin Uecker details how GCC compiles nested functions that access variables from an enclosing function, explaining that such functions are lowered early in the middle-end. Variables referenced by the nested function are gathered into a single synthetic struct, with a pointer to that struct passed to the nested function instead of using older stack-frame-pointer techniques like those in Pascal.