Forward declaration of structs are used all the time, but still involves importing a header. The motivation is to not allow developers to dip into the structure directly. I.e. look at CFString
. It is implemented as a struct, but you can't touch the structure contents directly. Instead, there is a full API for manipulating the struct contents. This allows CFString's implementation details to change without breaking binary compatibility.
In your header (ideally the header that defines whatever API is associated with TBXMLElement*
):
TBXMLElement.h:
typedef const struct TBLXMLElement *TBXMLElementRef;
extern TBXMLElementRef TBLXMLCreateElement();
... etc ...
Then, in the implementation file containing the implementation of the TBLXMLElementAPI:
TBXMElement.c (assuming it is a C file):
typedef struct __TBLXMLElement {
... struct members here ...
} TBLXMLElement;
TBXMLElementRef TBLXMLCreateElement()
{
return (TBXMLElementRef)malloc(sizeof(TBLXMLElement));
}
... etc ....