2

I'm trying to use a C++ library in my iOS app and I'm wrapping the library in Objective-C++ code.

One of the header files my iOS app relies on is a C++ header file that declares a few datatypes (enums and classes) inside namespaces. When I include the C++ header iOS land, I get compiler errors about the namespace keyword not being recognized.

Short of creating Objective-C++ wrapper classes for all of the C++ namespaced versions, is there another way to bring over the C++ headers?

1 Answer 1

4

The only thing you can do is wrap your C++ header imports in an #ifdef __cplusplus directive, which guarantees that other Objective-C++ and C++ headers can see the values of those namespaced enums and data types. There will always be some form of C++ header tainting if you use an unchecked include.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.