C ++ integration along with objective-c in iOS project

I was tasked with adding C ++ code to an iOS project.

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

I added these files to the Xcode iOS project and added library paths and header search paths in the project settings, but I get compiler errors.

For example, one of the .hpp files contains:

`#include <string>`

and the error I get is "String: There is no such file or directory"

In the same hpp file there is a namespace declaration:

`namespace FooBar`

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

I came directly to iOS programming, so my experience was mainly with objective-c. Can anyone offer any recommendations in terms of project settings, search paths, etc., to make C ++ work together with obj-c?

Thanks in advance!

+3
source share
1 answer

The Objective-C file that includes this header may not be in Objective-C ++ mode. You usually fix this by making your implementation .mminstead .m, since the latter is pure Objective-C.

+4
source

Source: https://habr.com/ru/post/1789753/


All Articles