An opaque structure is a C structure type whose member definition remains hidden from code using its interface. Client code can declare and pass pointers to the type without knowing its layout. section 11.2
Forward-declared library type
A header can expose the type and its operations without defining its members: struct toto; struct toto* toto_get(void); void toto_destroy(struct toto*); void toto_doit(struct toto*, unsigned); Client code can obtain, destroy, and operate on a toto object through its pointer. The implementation translation unit supplies the hidden structure definition. section 11.2
The interface relies on these rules:
- Uses pointers to an incompletely known structure type; the structure definition itself need not be visible to the client or compiler using the interface. section 11.2
- Separates library interface from implementation while allowing functions to return and accept pointers to the hidden object. section 11.2
- Keeps null-pointer handling visible when the interface writes pointer types explicitly; hiding pointers inside a typedef can conceal that special value. section 11.2
/* forward declaration of struct toto */ struct toto; struct toto* toto_get(void); void toto_destroy(struct toto*); void toto_doit(struct toto*, unsigned);
Browse the minimal forward declaration and function declarations for an opaque structure interface. section 11.2

