Windows+Objective-Cで「Hello Objective-C World」
結構Windows Objective-Cで検索して頂いているので「Hello Objective-C World」を書いておきます。
(今頃かよ!)
ソース
- hello.m
#import "hello.h" @implementation TestClass - (void) getMessage { printf("Hello Objective-C World\n"); } @end int main(int argc, char *argv[]) { id obj = [TestClass alloc]; [obj getMessage]; return 0; }
- hello.h
#import <stdio.h> #import <objc/Object.h> @interface TestClass : Object - (void) getMessage; @end
CC = gcc CFLAGS = -lobjc all: hello.m hello.h $(CC) -o hello.exe hello.m $(CFLAGS) clean: rm -f hello.exe
実行
Mingw32やCygwin環境でも動くと思います。
ほら、この通り。
$ make
gcc -o hello.exe hello.m -lobjc$ ./hello.exe
Hello Objective-C World