Skip to content

Instantly share code, notes, and snippets.

@thoughtpolice
Created July 1, 2009 11:26
Show Gist options
  • Save thoughtpolice/138728 to your computer and use it in GitHub Desktop.
Save thoughtpolice/138728 to your computer and use it in GitHub Desktop.
~/src/C-ObjC-Blocks $ cat t.c
#include <stdio.h>
#include "blocks_runtime.h"
int main() {
int x[5] = { 0, 1, 2, 3, 4 };
for(int i=0; i<5; i++) {
void (^f)(int) = ^(int y) { printf("v: %d\n", i+y); };
for(int j=10; j>=1; j--)
f(j);
printf("\n");
}
return 0;
}
~/src/C-ObjC-Blocks $ ~/src/llvm/Debug/bin/clang -fblocks -lobjc -framework Foundation -o t t.c blocks_runtime.m
blocks_runtime.m:397:18: warning: comparison of distinct pointer types ('void *' and 'struct psy_objc_class *')
if(self->isa == &_NSConcreteStackBlock && self->flags & BLOCK_HAS_DESCRIPTOR)
~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
blocks_runtime.m:416:18: warning: comparison of distinct pointer types ('void *' and 'struct psy_objc_class *')
if(self->isa == &_NSConcreteStackBlock && // A Global block doesn't need to be released
~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
2 diagnostics generated.
~/src/C-ObjC-Blocks $ ./t
v: 10
v: 9
v: 8
v: 7
v: 6
v: 5
v: 4
v: 3
v: 2
v: 1
v: 11
v: 10
v: 9
v: 8
v: 7
v: 6
v: 5
v: 4
v: 3
v: 2
v: 12
v: 11
v: 10
v: 9
v: 8
v: 7
v: 6
v: 5
v: 4
v: 3
v: 13
v: 12
v: 11
v: 10
v: 9
v: 8
v: 7
v: 6
v: 5
v: 4
v: 14
v: 13
v: 12
v: 11
v: 10
v: 9
v: 8
v: 7
v: 6
v: 5
~/src/C-ObjC-Blocks $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment