Rewritten objc.m to use Objective-C objects (NSData, NSString and NSFileHandle) and provided build instructions using clang on both OS X and Linux.
This commit is contained in:
22
o/objc.m
22
o/objc.m
@@ -1,7 +1,21 @@
|
|||||||
#import <Cocoa/Cocoa.h>
|
/*
|
||||||
|
Build on OS X:
|
||||||
|
clang -framework Foundation -fobjc-arc objc.m -o objc
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
Build on Linux with GNUstep:
|
||||||
|
clang `gnustep-config --objc-flags` `gnustep-config --base-libs` -fobjc-nonfragile-abi -fobjc-arc objc.m -o objc
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
{
|
{
|
||||||
NSLog(@"Hello, World!\n");
|
@autoreleasepool
|
||||||
return 0;
|
{
|
||||||
|
NSFileHandle *_stderr = [NSFileHandle fileHandleWithStandardError];
|
||||||
|
NSString *string = @"hello, world\n";
|
||||||
|
NSData *data = [string dataUsingEncoding:[NSString defaultCStringEncoding]];
|
||||||
|
[_stderr writeData:data];
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user