On Tue, Sep 28, 1999 at 09:46:31PM -0700, Guy Harris wrote:
>
> FT_BOOLEAN could be used for Boolean bitfields; you might want some way
> of specifying the strings for "true" and "false" - alas, standard C
> doesn't have a good way of initializing unions (it has one sufficient to
> allow the standard to say which element gets initialized to its version
> of zero, but that's it), so replacing "vals" in the "header_field_info"
> structure with a union of "struct value_string *" and, say, a pointer to
> an array of two "char *"s would be painful - but making it a "void *",
> although it might remove some type checking, would work.
Or I could avoid the problem by making FT_BOOLEAN accept a normal val_string
pointer. Then I wouldn't have to worry about initializing unions, and
then the programmer wouldn't have to remember which order the strings were in:
struct {
char *true_string;
char *false_string;
} truths;
(which would be plausable, because one normally, at least in English,
says "true/false", not "false/true")
or
struct {
char *false_string;
char *true_string;
} truths;
(which would be plausible, if one thinks of truths as an array, with the
index representing the truth value:
truths[0] = false_string;
truths[1] = true_string;
)
--gilbert