Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 33 lines (26 sloc) 0.544 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/*
Test your installation by running:

clang -o sample -fblocks sample.c -lBlocksRuntime && ./sample

The above line should result in:

Hello world 2

If you have everything correctly installed.
*/

#ifndef __BLOCKS__
#error must be compiled with -fblocks option enabled
#endif

#include <stdio.h>
#include <Block.h>

int main()
{
  __block int i;
  i = 0;
  void (^block)() = ^{
    printf("Hello world %d\n", i);
  };
  ++i;
  void (^block2)() = Block_copy(block);
  ++i;
  block2();
  Block_release(block2);
  return 0;
}
Something went wrong with that request. Please try again.