开发者

How to use standard c++ libraries in xcode?

I have a new empty xcode project. It gives me "No such file or directory" compile error when I try to import some c++ 开发者_开发技巧libraries such as <iostream>, <string>, and <map>

What do I have to do to import c++ libraries into xcode for so I can call their functions in objective-c?


If you are just trying to write C++ code in Xcode instead of calling C++ libraries in your objectiveC project you can create a C++ project. I just created a new project using the "Command Line Tool" template and selected C++ as the language.

I could then add the following lines without the compiler complaining.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>

To use items from the std c++ libraries you prefix them with std::

int main (int argc, const char * argv[])
{
    std::cout << "Hello World!";

    return 0;
}

I was actually searching stack overflow for the reason std:: is necessary in Xcode...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜