[Tfug] Developer question

Robert Hunter hunter at tfug.org
Mon Jul 2 18:00:44 MST 2007


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 */
       RED = 0,
       GREEN,
       BLUE,
       /* add new colors above this line */
       COLOR_T_ENTRIES
};

static const char *
colornames[COLOR_T_ENTRIES] = {
       "Red",
       "Green",
       "Blue",
};


-- 
Rob




More information about the tfug mailing list