Is it possible to do forward declaration of a C++ class, which is inside a namespace, in an Objective C header file?
C++ class to forward declare in Objective C:
namespace name
{
class Clazz
{
};
}
I know I can if the C++ class is not in a namespace. Taken from http://www.zedkep.com/blog/index.php?/archives/247-Forward-declaring-C++-classes-in-Objective-C.html
Any thoughts?
Thanks guys!
You just declare it as usual, and wrap it in the C++ #ifdef
check when the header is also included in C and/or ObjC translations:
#ifdef __cplusplus
namespace name {
class Clazz;
} // << name
#endif
For obvious reasons, you cannot use name::Clazz
in a C or ObjC translation, so this works out perfectly. You either need the forward declaration in the C++ translation, or it does not need to be visible to C or ObjC.