[cfe-dev] Using blocks with standard C?

John McCall rjmccall at apple.com
Thu Jul 12 13:22:28 PDT 2012


On Jul 12, 2012, at 12:26 PM, Jacob Carlborg wrote:
> I don't know if this is the right place to ask, but anyway. I'm using 
> the D programming language, which is ABI compatible with standard C. It 
> doesn't not support blocks. My question is then, is it possible to 
> somehow call a C function which accepts a block using some kind of 
> struct and/or functions from the runtime?

The block layout is documented here:
  http://clang.llvm.org/docs/Block-ABI-Apple.txt

Basically, you would want to fill one of those out on the stack and pass
the address to the routine you're calling.

John.



More information about the cfe-dev mailing list