I am porting a project to the iPhone system and I am facing the following problem:
I have an header containing c++ templates
If I rename it to .mm, it does not compile (because it should be an header) and if I keep it as .h, it is interpreted as an objective C header
Do you have a workaround to fix this issue?
Thanks in advance!
Regards,
edit: add error message and code
template <typename T>
class CML_Matrix
{
public:
//rest of teh template
};
error message is “cannot find protocol declaration for typename”
Wrap it in
This way, the templates will be silently ignored when the file is included in a C or Objective C (.m) source.
You can also have some Objective C-only constructs wrapped in
EDIT: you can, alternatively, rename your sources (not the header!) to .mm. Since it’s a mixed ObjC/C++ project, you’ll probably have to instantiate/call C++ classes at some point; for that, you’ll need Objective C++ anyway. Never tried this, though.