Created
January 18, 2013 15:07
-
-
Save rtsisyk/4565163 to your computer and use it in GitHub Desktop.
GCC 4.7 on Debian does not compile simple Objective C++ test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#import <objc/runtime.h> | |
#include <assert.h> | |
@interface Object | |
{ | |
Class isa; | |
} | |
/* Required by the NeXT runtime. Does nothing. */ | |
+ (id) initialize; | |
/* Creating instances */ | |
+ (id) new; | |
+ (id) alloc; | |
- (id) init; | |
- (id) free; | |
/* Auxiliary methods. */ | |
+ (Class) class; | |
+ (Class) superclass; | |
+ (const char *)name; | |
- (const char *)name; | |
@end | |
@implementation Object | |
+ (id) initialize | |
{ | |
return self; | |
} | |
+ (id) new | |
{ | |
return [[self alloc] init]; | |
} | |
+ (id) alloc | |
{ | |
return class_createInstance (self, 0); | |
} | |
- (id) init | |
{ | |
return self; | |
} | |
- (id) free | |
{ | |
return object_dispose ((id)self); | |
} | |
+ (Class) class | |
{ | |
return self; | |
} | |
+ (Class) superclass | |
{ | |
return class_getSuperclass (self); | |
} | |
+ (const char *)name | |
{ | |
return class_getName (self); | |
} | |
- (const char *)name | |
{ | |
return class_getName (isa); | |
} | |
@end | |
@interface Frob: Object | |
@end | |
@implementation Frob: Object | |
@end | |
int proc() { | |
@throw [[Frob alloc] init]; | |
return 1; | |
} | |
int foo() | |
{ | |
@try { | |
return proc(); | |
} | |
@catch (Frob *ex) { | |
printf("Catch... "); | |
return 0; | |
} | |
@finally { | |
printf("Finally... "); | |
} | |
} | |
int main(void) | |
{ | |
foo(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment