[Tfug] Developer question
Bexley Hall
bexley401 at yahoo.com
Fri Jul 6 14:42:31 MST 2007
Greetings!
--- Robert Hunter <hunter at tfug.org> wrote:
> On 7/2/07, Bexley Hall <bexley401 at yahoo.com> wrote:
> > I have a set of manifest constants that are used,
> > among other things, as indices into different
> > tables.
>
> Howdy, Don.
>
> There is probably more than one way to skin this
> cat, but it sounds like
> you are looking for a minimalist approach. Shy of
> writing your own
> preprocessor script, as Mike suggested, one cheap
> thing you could do is
> explicitly specify the size of the "table".
>
> enum color_t {
> /* must begin with 0, so sayeth the standard
> */
Actualy, that's just the example context... you can
begin with damn near *anything*! :>
> RED = 0,
> GREEN,
> BLUE,
> /* add new colors above this line */
> COLOR_T_ENTRIES
> };
>
> static const char *
> colornames[COLOR_T_ENTRIES] = {
> "Red",
> "Green",
> "Blue",
> };
Yes, but all that does is guarantee that colornames[]
has the right number of *entries*. It doesn't force
the developer (maintainer) to *set* those entries to
their correct values, etc.
Obviously, I don't trust people to dot i's and
cross t's :< And, I get tired of having to
explain why a "future bug" was NOT a bug in *my*
codebase but, rather, caused by someone dicking
around and not understanding the ramifications
of his/her changes :< (note that this sort
of bug could remain dormant for a long time -- thus
potentially VERY expensive to fix!)
I am hoping to come up with a scheme that cripples
the build unless some effort at twiddling the
associated data structures is made, etc.
--don
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/
More information about the tfug
mailing list