This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Private data members
- From: Vladimir Prus <vladimir at codesourcery dot com>
- To: gdb at sources dot redhat dot com
- Date: Wed, 29 Jul 2009 12:45:32 +0400
- Subject: Private data members
I have run into a case when it's desirable that all modifications
of a certain structure field in GDB codebase go via function that
can enforce necessary invariants. Specifically, the ignore_count
in struct breakpoint does not make any sense for tracepoint, therefore
I want to introduce a function that will throw if non-zero ignore count
is ever set for a tracepoint.
At the moment, there are at least 3 places that directly assign
a value to that field, and while I can convert them easily, nothing
will prevent a direct assignment to appear in future. In C++,
one would use 'private' visibility for that member, but it's not
available in C. So, how about introducing a small convention --
that members with names ending in '_' are 'private' and should
never be accessed by outside code. Another alternative is to
modify the comment on ignore_count, but that is much more likely
to be ignored.
Comments?
- Volodya