Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 950
Mark Ingram Avatar asked Feb 13 '13 11:02

Mark Ingram


1 Answers

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.

like image 157
Mark Ingram Avatar answered Oct 08 '22 15:10

Mark Ingram