Referred Question: Problem when #import C++ Header File in iPhone/iPad Project
Well, my project is relatively huge and cannot solve that either changing ALL or PART OF my project files .m
to .mm
or changing the ALL or PART OF file types in File Inspector
.
That is because both my colleagues and library authors DOES NOT follow the C++ standard strictly, such as assigning void*
to int*
and other various violations. Objective C would allow these and just gives warnings.
The C++ header file I want to #import
is a library. It uses keyword namespace in its header, while its implementation is in an .a
assembly file. That means it is nearly impossible to hack them. Besides that, my project also includes other libraries that are compatible only with Objective C.
Does anyone know how to solve this?
The ways I could imagine is as follows:
Find an alternative for namespace, but still I want to write codes like
QCAR::Renderer
in my project.Tell the compiler to recognized C++ header(Well, that might not be possible)
EDIT
#ifdef __cplusplus
# include MyCPPHeader.h
#endif
If I use that, would MyCPPHeader.h
really get included in an Objective-C environment? I guess not. And that's against the principles of not hacking libraries.
EDIT
Even I changed these .mm
files to include that C++ Header, i would get an link error saying Undefined symbols for architecture armv7:
. This happens when my .mm
files including .h
headers in other libraries.