Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode Objc header cannot find standard memory library

in our project we ran into a problem considering the include of the standard library memory. #include <memory> in an Objective-C headerfile causes the error 'memory' file not found. The header file is imported for an external static library and it was already working once when we checked out a previous version of the library.

With this previous version the same error occurs now and since then the only change we made on this test project for the library is the update of XCode to version 9.2 from previously 8.3.

Did anyone encounter a similar issue when using an external library and updating XCode or might drop me a hint, what could be cause for this behaviour?

like image 571
Mr. Meeseeks Avatar asked Sep 01 '25 21:09

Mr. Meeseeks


1 Answers

memoryis a C++-only header. You can only include it to C++ and Objective-C++ files. You should change the file suffix from .m to .mm to change a Objective-C file to an Objective-C++ file.

If you want put the include into an Objective-C header and include it into Objective-C and Objective-C++ code as well, you should enclose the include with appropriate #ifdef, e.g.:

#ifdef __cplusplus
#include <memory>
#endif

Note: You can still only use the declarations from <memory> in (Objective-)C++.

like image 107
clemens Avatar answered Sep 03 '25 11:09

clemens