Mark Ingram Mark Ingram - 26 days ago 9
C++ Question

XCode 4.6 / Clang 4.2 can't find C++11 headers

I'm trying to include some C++11 headers in an iOS project, but XCode / Clang can't find them. I'm trying to include

<memory>
,
<functional>
and a few others. But it complains that it can't find them during the build (despite me right-clicking and "Jumping to definition" which loads the file...). How do I get my project to use C++11 header files?


Lexical or Preprocessor Issue 'memory' file not found

Lexical or Preprocessor Issue 'functional' file not found


My project settings are:


C++ Language Dialect = C++11 [-std=c++11]

C++ Standard Library = libc++ (LLVM C++ standard library with C++11 support)


The files which try to include the headers are
.h
for a templated class and a
.h
that is included from a
.mm
implementation.

Answer

It turned out that Clang's error message was unhelpful: the root include for these files was a .m file, compiling as Objective-C, so I renamed it to .mm, to compile as Objective-C++, and it started working.

Comments