看看下面这个不知道怎么就是报错呢?cc的时候加了 -framework Foundation 报的错是:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_Che", referenced from:
objc-class-ref in 1类-AWRDrA.o
"_OBJC_IVAR_$_Che.lunzi", referenced from:
_main in 1类-AWRDrA.o
"_OBJC_IVAR_$_Che.shisu", referenced from:
_main in 1类-AWRDrA.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation
代码如下:
#import <Foundation/Foundation.h>
@interface Che : NSObject
{
@public
int lunzi;
int shisu;
}
@end
int main()
{
Che *p = [Che new];
p->lunzi = 4;
p->shisu = 130;
NSLog(@"车的轮子有%d个,车的时速是%dkm/h",p->lunzi,p->shisu);
return 0;
} |
|