有什么方法可以在不使用 GNUStep 的情况下在 ubuntu 上编译目标 c 程序?我想使用默认的 C 标准库,除了 Objective-C 的 OOB 语法。我现在遇到的问题是,一旦我掌握了所有方法,我需要一种方法来调用它们。在 Mac 中,我只会分配并初始化它,但在 Linux 上,当我尝试编译它时,clang 只会给我一个错误。
#include <stdio.h> // C standard IO library (for printf)
#include <stdlib.h> // C standard library
// Interface
@interface test
-(void)sayHello :(char *)message;
@end
// Implementation
@implementation test
-(void)sayHello :(char *)message {
printf("%s", message);
}
int main(int argc, char *argv[]) {
test *test = [[test alloc] init];
[test sayHello:"Hello world"];
}