Snow Leopard breaks GCC?
fraction.m: In function 'main':
fraction.m:6: warning: 'Fraction' may not respond to '+alloc'
fraction.m:6: warning: (Messages without a matching method signature
fraction.m:6: warning: will be assumed to return 'id' and accept
fraction.m:6: warning: '...' as arguments.)
fraction.m:7: warning: 'Fraction' may not respond to '-init'
fraction.m:18: warning: 'Fraction' may not respond to '-free'
I have installed the most recent version of XCode and the iPhone SDK.
Can anyone shed some light on this? My program can be found below. Thank you!
#import <stdio.h>
#import <objc/Object.h>
/* Interface */
@interface Fraction: Object
{
int numerator;
int denominator;
}
-(void) print;
-(void) setNumerator: (int) n;
-(void) setDenominator: (int) d;
-(int) numerator;
-(int) denominator;
@end
/* Implementation */
@implementation Fraction;
-(void) print
{
printf ("%i,%i", numerator, denominator);
}
-(void) setNumerator: (int) n {
numerator = n;
}
-(void) setDenominator: (int) d {
denominator = d;
}
-(int) numerator {
return numerator;
}
-(int) denominator {
return denominator;
}
@end
#include "fraction.h"
int main (int argc, char *argv[])
{
// Fraction *myFraction = [[Fraction alloc] init];
Fraction *myFraction;
myFraction = [Fraction alloc];
myFraction = [myFraction init];
// Set fraction to 1/3
[myFraction setNumerator: 1];
[myFraction setDenominator: 3];
// Display the fraction
printf ("The value of the fraction is %i/%i", [myFraction numerator], [myFraction denominator]);
[myFraction free];
return 0;
}
iMac, Mac OS X (10.6)