secret
Created

  • Download Gist
._src_darwin_greet.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
//
// wrapper file, calls Greeting::Greet via Objective-C
//
 
#if __cplusplus
extern "C" {
#endif
 
#include <CoreFoundation/CoreFoundation.h>
#include <iostream>
 
void greet() {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Greeting *g = [[Greeting alloc] init];
[g autorelease];
[g greet];
[pool release];
std::cout << "Hello Steve!" << std::endl;
}
 
#if __cplusplus
}
#endif
._src_darwin_greeting.h
Objective-C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
//
// Greeting.h
// Untitled
//
// Created by Lee Hambley on 9/21/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
 
#import <Cocoa/Cocoa.h>
 
 
@interface Greeting : NSObject {
 
}
 
@end
._src_darwin_greeting.mm
Objective-C
1 2 3 4 5 6 7 8
//
// Untitled
//
// Created by Lee Hambley on 9/21/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
 
#import "greeting.h"
._src_greet.h
C
1
void greet();
._src_main.cpp
C++
1 2 3 4 5 6
#include <greet.h>
#include <iostream>
 
int main(){
greet();
return 0;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.