How to compile C++0x code for the iPhone and iPhone simulator
We have a mathematics/scientific application for protein visualization written in C++ using OpenGL. It was written over the last couple of years and makes extensive use of C++0x features found in GCC 4.4 and later. (It also compiles with Microsoft Visual C++ 10 on Windows, which supports many C++0x features.)
We want to release an iPhone/iPad version, so we need to port it from Linux/Windows to the iPhone. We've ported similar programs with very little effort--add a handful of Objective C files, and done!--however, due to the C++0x features used here we've got a problem. Xcode on OS X uses GCC 4.2.1 (from 2007) which predates GCC's C++0x support. It seems a huge step backwards to rewrite all this beautiful C++ 0x c开发者_Go百科ode to not use C++0x features, and we really don't want to maintain a backported codebase when the march towards C++0x is clear.
Is there any way to use GCC 4.5 (or 4.6, from SVN) to target the iPhone and iPhone simulator? If so, how? Preferably, from within Xcode, since the click-and-run/click-and-debug functionality is very useful. It'd be great to be able to enter "GCC 4.6" in the "C/C++ Compiler Version" box in Xcode and just have everything work.
(As an aside, the top-of-the-tree version of Clang--as of just yesterday!--supports some C++0x features, but doesn't yet support lambda expressions so it's probably out for us for now.)
Off the top of my head, I'm going to say there probably isn't a very clean or easy way to do this, until Apple officially supports it. You probably already know this, but the reason Xcode uses an older version of GCC is that Apple makes extensive modifications to the GNU toolchain, and releases their version under the APSL (which is incompatible with the GPL) . So for the most part, you can consider their version of GCC to be a complete fork. I ran into this problem when trying to port the Apple version of the toolchain to Linux. I'd had some limited success, but it is not a small undertaking...
精彩评论