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

printf

macrumors regular
Original poster
Aug 27, 2008
105
0
i've heard it mentioned that it's possible to write c code along side objective c, and i'm interested in learning how to accomplish this. this will decrease the amount of time it takes to get some simple iphone apps up and running because it will keep me from having to port many libraries of c/c++ code over to objective c (NOT a fun task). and in line with that thought, since i do a lot of windows programming, it would obviously be nice to have some portability between platforms so code i write on one can easily be moved over with little effort. makes sense, right? :)

i would appreciate articles/tutorials/references that explain this, or if this is a relatively trivial thing that can be explained in a paragraph or two, i'd appreciate your taking the time to enlighten me. :)

finally, if you were in my shoes at one point and are now a hardened obj c developer who's about to sing the praises of obj c and how easy it is to learn... well, actually, by all means do so. but please address my previous concerns about portability while you're at it.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Objective-C is a pure superset of C: you can intermix C and Objective-C wherever you wish: you can call C functions etc without issue for Objective-C methods.

C++ is a little bit different: you need to use Objective-C++. Even that's not particularly difficult. Have fun :)
 

moral-hazard

macrumors regular
Jul 27, 2009
197
3
As stated...no issue with intermixing Obj-C and C.

I use low level C code in many instances for writing my own data structures - generally it's helpful to write an objective-C wrapper around whatever C feature you are trying to use (assuming it's simple enough to do so).
 

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
Objective C and C are already combined...

because Objective C is C, a superset thereof, with just a few added forms of macro expansion plus a small runtime to support a little bit of extra punctuation abuse.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.