23 Aug 2009 Omnifarious   » (Journeyer)

C++ on the iPhone

While I do not recommend that anybody develop anything for the iPhone, I was recently investigating something about it.

I would like to repeat that I do not recommend that anybody develop anything because Apple's policies make it questionable as to whether or not your app will ever make it to the app store at all. They have no compunctions about refusing apps for the most bizarre of reasons, and even worse, refusing apps because either Apple or AT&T perceives them as somehow competing.

If you want to develop for a mobile phone platform, go for the Android. That is a clear and open market.

That being said, I did have reason to investigate C++ on the iPhone recently, and I came across these 3 well-written articles by someone who's tried to develop C++ on several different mobile phone environments. I would like to point to them here because other people looking for this information should be able to find it easily, and so I can find it easily.

  • C++ on iPhone: Part 1 - in which its discovered that yes, constructors for global variables are indeed run before main starts and their destructors are called after main ends.
  • C++ on iPhone: Part 1a - Yeah, yeah, the last one didn't seem at all iPhone specific, but really I did run it on an iPhone and it worked just like it ought to.
  • C++ on iPhone: Part 2, Exceptions - Why yes, exceptions do indeed work, and there's even some hints that there's been an attempt at integration between Objective-(C/C++) 2.0 exceptions and C++ ones.
  • C++ on iPhone: Part 3, Run Time Type Identification - Yep, this works too.
  • Of BOOL and YES - BOOL is an evil Objective-C type that's really a typedef and a holdover from the days when C didn't have a bool type. Don't forget that there are many values that mean YES besides YES, so compare against NO if you have to compare. (IMHO, you should just always assign to a real bool type as the iPhone C compiler is C99 compliant and that does have bool).

So yes, it appears the iPhone does C++ just fine. That guy was promising to write more on how Objective-(C/C++) and C++ mixed. But I don't think he ever got around to it.

Syndicated 2009-08-22 12:10:58 (Updated 2009-08-22 12:20:38) from Lover of Ideas

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!