Re: Objective-C++
Re: Objective-C++
- Subject: Re: Objective-C++
- From: "Wesley Smith" <email@hidden>
- Date: Fri, 8 Feb 2008 15:11:49 -0800
Also, if you're doing cross-platform work, you might think about using
the Abstract Factory design pattern for abstracting out OS details to
a generic interface. You can even put the declaration of the ObjC
class in the .mm and maintain a pure C++ header file for use elsewhere
in your code.
wes
On Feb 8, 2008 3:06 PM, John Stiles <email@hidden> wrote:
> Any file that #includes <iostream>, either directly or indirectly via
> another header, needs to be a .cpp or .mm in order to work. .c or .m
> will not work.
>
>
>
>
> Philip Bridson wrote:
> > Thanks both to Dave and John,
> >
> > I am using .mm for my implementation files but it is in the .h files i
> > am having problems. Do I need to put the entire class, including
> > deceleration in an .mm file?
> >
> > Thanks guys.
> >
> > Phil
> >
> > On Feb 8, 2008, at 2:51 PM, Philip Bridson wrote:
> >
> >
> >> I am trying to write using Objective-C++. I have read the docs and
> >> understand what I can and can't do with it but I have a really basic
> >> problem. When I put #include <iostream> in my header files I get an
> >> error saying that the file cannot be found? Why is this?
> >>
> >
> > Most likely because the compiler doesn't think that it's compiling an
> > objective-c++ file, which means that it isn't using the C++ header
> > search paths. What extension are you using for your filename? You have
> > to use .mm to tell the compiler that it's objective-c++.
> >
> >
> >> Also when creating the file, do I create a C++ file or an Obj-C file
> >> or doesn't it matter?
> >>
> >
> > It should be a .mm file.
> >
> >
> >> Finally, I want to do some thing like this
> >>
> >> #ifdef _MAC_OS_X
> >> //do some obj-c code
> >> #endif
> >>
> >> #ifdef _WIN32
> >> //use WIN32 API coding
> >> #endif
> >>
> >
> > #ifdef __OBJC__
> > //objc only stuff
> > #endif
> >
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden