buildlib: supply -fPIC or -fpic if supported
[blocksruntime.git] / sample.c
blob2d6e379e6948fe305a764e8b061d9f8920a37b1a
1 /*
2 Test your installation by running:
4 clang -o sample -fblocks sample.c -lBlocksRuntime && ./sample
6 The above line should result in:
8 Hello world 2
10 If you have everything correctly installed.
13 #ifndef __BLOCKS__
14 #error must be compiled with -fblocks option enabled
15 #endif
17 #include <stdio.h>
18 #include <Block.h>
20 int main()
22 __block int i;
23 i = 0;
24 void (^block)() = ^{
25 printf("Hello world %d\n", i);
27 ++i;
28 void (^block2)() = Block_copy(block);
29 ++i;
30 block2();
31 Block_release(block2);
32 return 0;