简体   繁体   中英

C++ Standard Library found in .mm files but not in the .h (Xcode 4.5 LLVM GCC 4.2)

I'm trying to use std::vector in a iOS6.0 application developped in Xcode 4.5 compiled with LLVM GCC 4.2 and I renamed with the .mm extension the files I'm using C++ in. But for some reason, the headers associated with those .mm don't get compiled I've got the following error :

Vector: No such file or directory

I've tried import, include. It works if I only include it in the .mm though.

Any idea what I'm doing wrong ?

Thank you

Webaba

RESOLVED : carefully check for other .m files potentially including this header. (not only the one implementing the class) I missed one.

Make sure that ever file including the headers is compiled as an Objective-C++ or a C++ file. You can do this by going selecting a source file, and in the File Inspector of the Utilities panel, you can set how Xcode should compile your file.

The same would happen if you were trying to compile a C source file which included Objective-C headers, for example.

Edit: if the command used to compile contains anything like -nostdinc or -nostdinc++ , then you might have to change your project settings. There should be a setting in the section LLVM GCC 4.2 - Language which is labelled Use Standard System Header Directory (for me this is the last setting of that section). Make sure it is set to yes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM