I'm no C++ guru, so I'm hoping someone can help me by explaining why
the following gives a compiler error:

//MyObjC.h
@interface MyObjC : NSObject {}
@end

//MyObjC.mm
#import "MyObjC.h"
#include "MyClass.h" //provides MyClass, a C++ class
#include <tr1/memory>

using std::tr1::shared_ptr;

@interface MyObjC ()

@property (assign, readwrite, nonatomic) shared_ptr<MyClass> foo;

@end

@implementation MyObjC
@synthesize foo; // gives compiler error: instance variable 'foo' has
unknown size

@end


The definitions for both shared_ptr and MyClass are available, as far
as I can tell. Furthermore, the following compiles without error:
//MyObjC.h
#include <tr1/memory>
#include "MyClass.h"

@interface MyObjC : NSObject
{
std::tr1::shared_ptr<MyClass> foo;
}
@end

//MyObjC.mm
#import "MyObjC.h"
#include "MyClass.h" //provides MyClass, a C++ class
#include <tr1/memory>

using std::tr1::shared_ptr;

@interface MyObjC ()

@property (assign, readwrite, nonatomic) shared_ptr<MyClass> foo;

@end

@implementation MyObjC
@synthesize foo; // gives compiler error: instance variable 'foo' has
unknown size

@end


Thus, I'm lead to believe this is an issue with runtime synthesizing
of the ivar, but I'm at a loss to explain why it should be so. I would
like to keep the C++ out of the header file if possible so that I can
use standard Objective-C when importing the header file in client
modules.

Any guidance from C++ gurus?

Thanks,
Barry
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to