3

I've been tasked with adding some c++ code into an iOS project.

The c++ code comes in the form of several libs (.a), and header files with the extension .hpp

I have added these files into the XCode iOS project, and added the paths to the library and header search paths in the project settings, but I am getting compiler errors.

For example, one of the .hpp files contains:

`#include <string>` 

and the error I am getting is "String: No such file or directory"

In the same hpp file there is a namespace declaration:

`namespace FooBar` 

and there is an error on this line is "expected '=', ',', ';', 'asm' or 'attribute' before 'FooBar'"

I came straight into iOS programming so my experience has been primarily with objective-c. Can anyone offer any advice in terms of the project settings, search paths etc in order to get the c++ working alongside the obj-c?

Thanks in advance!

1 Answer 1

4

It could be that the Objective-C file that's including this header isn't in Objective-C++ mode. Usually you fix this by making your implementation a .mm file instead of .m since the latter is pure Objective-C.

Sign up to request clarification or add additional context in comments.

1 Comment

Amending my obj-c headers and implementation files as you advised seems to have done the trick! Thank you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.