Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

paulmcco

macrumors newbie
Original poster
Jul 26, 2011
5
0
I have written a program in c++...it includes a bunch of header files and whatnot...I would like to build a user interface for this project using cocoa...can this be done? do I use a carbon application? would I have to re-write my c++ project at all?

I would like to use cocoa because the interface can have more objects...how different are objective C files(.m)...is it possible to incorporate the two different languages?
 
Last edited:
use .mm and -ObjC++

i've found yes, i can use c++ files in my obj-c wrapper.
two steps, rename your main.m -> main.mm
and if using gcc from command line, change -ObjC -> -ObjC++
i think xcode changes over automatically if you just change the extension.

i declare my classes completely in their .h files, so i don't know how the linker treats .cpp objects, what flags you need to integrate them right.
 
GCC itself will determine the language from the source code extension. There's no need to add -ObjC or -ObjC++. Just name you source files .m or .mm respectively.
 
obj-c and c files

thnx so much to jiminaus for making the info flow!
from a noob POV, looks like obj-c and c++ can be used side by side within a c method such as main().

but of course i don't go passing obj-c instantiations to c++ and vice versa...

i think of obj-c as java, although it is said that its VM is "thinner, very thin layer", but still it is more like bytecode than c++ which retains a "reality" to its pointers to actual realms within the SRAM... ocj-c is more like the "HANDLE system of win-32 programming?
 
thnx so much to jiminaus for making the info flow!
from a noob POV, looks like obj-c and c++ can be used side by side within a c method such as main().

but of course i don't go passing obj-c instantiations to c++ and vice versa...

i think of obj-c as java, although it is said that its VM is "thinner, very thin layer", but still it is more like bytecode than c++ which retains a "reality" to its pointers to actual realms within the SRAM... ocj-c is more like the "HANDLE system of win-32 programming?

You can have pointers ObjC objects in C++, and vice versa. ObjC++ will even call the constructors and destructors of C++ instance variables of ObjC classes for you.

There's no bytecode, no difference between pointers in ObjC and C++. Your perception is mistaken.
 
i think of obj-c as java, although it is said that its VM is "thinner, very thin layer", but still it is more like bytecode than c++ which retains a "reality" to its pointers to actual realms within the SRAM... ocj-c is more like the "HANDLE system of win-32 programming?

Clang/LLVM isn't anything like JVM >.< Where do people get that?

ObjC compiles into native code with Clang/LLVM not some sort of bytecode. LLVM JIT was only used for OpenGL.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.