Aran Mulholland
Aran Mulholland

Reputation: 23935

Objective C, C++, Including two files with the same class name

I have an Objective C Class called Donald, I also have a C++ class called Donald in a static library that I would like to use in the same project. They both have a header file called Donald.h. Is there a way to do this?

Upvotes: 1

Views: 446

Answers (1)

JeremyP
JeremyP

Reputation: 86651

You can include both header files by specifying a bit more of the path e.g.

#import "staticlibraryheaders/Donald.h"
#import "Donald.h"

However, you might find that the code won't compile since you are declaring two types both called Donald. If the compiler sees:

Donald* duck;

How does it know to type duck as a pointer to an instance of the C++ class or the Objective-C class? You might be able to fix that if the C++ class is in a C++ namespace. However, that hits the limit of my C++ knowledge.

Upvotes: 1

Related Questions