文章标签 » closure

backup:在linux下使用clang的闭包特性

FROM:http://stackoverflow.com/questions/5907071/clang-block-in-linux
On Ubuntu Linux:

sudo apt-get install llvm
sudo apt-get install clang
sudo apt-get install libblocksruntime-dev

test.c:

#include 

int main() {
    void (^hello)(void) = ^(void) {
        printf("Hello, block!\n");
    };
    hello();
    return 0;
}

compile:

clang test.c -fblocks -lBlocksRuntime -o test
./test

Hello, block!

works fine.