On Apr 2, 2010, at 2:38 PM, Andy O'Meara wrote:
> Hey folks, quick question...
> 
> A have a couple vanilla NS object ptrs (e.g. NSWindow*) that I have to pass 
> through some cross-plaform C++ code until it ends up in a .mm file where 
> where the NS object is accessed.  The problem is that in the .cpp code, 
> there's no obvious way to declare a NSWindow ptr so that thinks will link 
> without complaint.  If, for example, in a key header I use:
> 
> #ifdef __OBJC__
>    #define NSWindowPtr   NSWindow*
> #else
>    #define NSWindowPtr   void*
> #endif
> 
> then everything of course compiles, but nothing links (since all the .cpp 
> object files are looking for proc arguments with void* while the .mm object 
> files are are declared with the real deal).
> 
> So, what can I replace that second macro with such that it meshes with ObjC's 
> typedef mangling scheme?

You can't fool C++ name mangling using typedefs or macros. But you can tell C++ 
that NSWindow is an opaque struct. Then you can use `NSWindow *` or `typedef 
NSWindow* NSWindowPtr` on both sides without trouble. 

    #ifdef __OBJC__
    # include <AppKit/AppKit.h>
    #else
    struct NSWindow;
    #endif


-- 
Greg Parker     gpar...@apple.com     Runtime Wrangler


_______________________________________________

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