Private data members
Michael Snyder
msnyder@vmware.com
Wed Jul 29 17:30:00 GMT 2009
Tom Tromey wrote:
>>>>>> "Volodya" == Vladimir Prus <vladimir@codesourcery.com> writes:
>
> Volodya> I have run into a case when it's desirable that all
> Volodya> modifications of a certain structure field in GDB codebase go
> Volodya> via function that can enforce necessary invariants.
>
> Volodya> At the moment, there are at least 3 places that directly assign
> Volodya> a value to that field, and while I can convert them easily,
> Volodya> nothing will prevent a direct assignment to appear in future.
>
> In the past somebody solved this same problem for struct value by
> putting the struct definition into value.c and adding a bunch of
> accessors.
>
> I'm lukewarm about this technique, but it can be made to work.
>
> Daniel's suggested approach would also be fine with me.
How about combining the two?
Define struct breakpoint in breakpoint.h, put any public members
in there, and then include a member "struct breakpoint_private"
that is only a forward declaration.
Then define "struct breakpoint_private" in breakpoint.c, so that
its members will be invisible outside of that module.
More information about the Gdb
mailing list