if have a routine like this which I want the main application to access…
char* get_widget_name(widget_t* w) {
return name(w);
}
both the following macro’s I want to “hide” while obviously using within get_widget_name
#define GET_WIDGET(self) (&(self)->base.widget)
#define name(self) (GET_WIDGET(self)->name)
I’m basically using unions in structures to “emulate” c++ inheritance in C.
You publish the information to be used in the main application in a header file. In this example, it might be:
And then in the implementation file (
widget.c), you define the structure contents and the macros and use them as you see fit, without making them available to the main application at all.