1. How to mixed C + +
Create a project with XCODE4, if the header of any file AAA.h joins
#include <string>
using namespace Std;
Compile run, you will find that the compilation does not pass, the prompt is:
' String ' File not found
The reason is that the file suffix should be changed from. m to. MM, so that it supports C + + mixed, all file suffixes that refer to C + + mixed AAA.h must be changed to. mm, otherwise it will still compile. Therefore, in order to insure, I generally will be so the file suffix all changed to. mm.
2. Selection of C + + standard library
If you chose 4.3 in deployment Target in summary instead of the default of Xcode, you might encounter another error when mixing C + +:
Clang:error:invalid deployment target for-stdlib=libc++ (requires IOS 5.0 or later)
Clang failed with exit code 1
The reason is that the C + + standard library in XCode's Build setting is selected by default
The libc++ (LLVM C + + standard library with C++11 support) option, which supports the latest new special of C++11,
But it only supports ios5 above, so if you want to use this option, there are two options:
The 1th option is to change deployment target to more than 5.0, generally not, because we generally want to support the lower the better, as far as possible to support the lower version of the iOS device.
The 2nd option is to change the C + + standard library option to libstdc++ (the GNU C + + standard library), which supports a minimum of 4.3.
How to mixed C + +