On 22 Jun 2010, at 10:56, David Chisnall wrote: > On 22 Jun 2010, at 10:51, Thomas Davie wrote: > >> The only problem I have remaining is that it appears that nowhere in >> Foundation.h is blocks_runtime.h ever imported. The result is that in my >> code, Block_copy and friends are inaccessible. I don't know where the >> appropriate place to include this is, could you add it in the right place >> and commit again? > > Richard, I think this one's for you... > > We only need to bother including blocks_runtime.h when using clang, since GCC > doesn't support blocks, so we can wrap it in a __has_include() test, but we > should probably also wrap it in a __has_feature() test to make sure we are > compiling with -fblocks (I'm not sure what happens if you include that header > without blocks support). > > How are we currently deciding whether to import the libobjc2 or ObjectiveC2 > headers in Foundation? I've not really checked, but we should be doing this > the same way...
Hi David, Some further testing (manually including blocks_runtime.h) reveals that there's still some problems, inserting a block into a collection appears to cause a segfault: #include "blocks_runtime.h" #include <Foundation/Foundation.h> int main (int argc, char ** argv) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSLog(@"a"); NSMutableArray *blockArray = [NSMutableArray array]; NSLog(@"b"); NSString *(^block)(int x) = ^(int x) { return [NSString stringWithFormat:@"Test %d", x]; }; NSLog(@"c"); NSString *(^block1)(int x) = Block_copy(block); NSLog(@"d"); [blockArray addObject:block1]; NSLog(@"e"); NSString *(^block2)(int arg) = [blockArray objectAtIndex:0]; NSLog(@"f"); NSLog(@"%@", block(4)); NSLog(@"%@", block2(5)); [pool release]; return 1; } This logs a,b,c,d, and then Seg Faults. Tom Davie _______________________________________________ Gnustep-dev mailing list Gnustep-dev@gnu.org http://lists.gnu.org/mailman/listinfo/gnustep-dev