[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: textutils -> od 2.0.14 bug - solved

From: Eric Backus
Subject: Re: textutils -> od 2.0.14 bug - solved
Date: Wed, 15 May 2002 16:15:54 -0700

From: "Jim Meyering" <address@hidden>

> +/* Ensure that for each member of `enum size_spec' there is an
> +   initializer in the width_bytes array.  */
> +struct assert_width_bytes_matches_size_spec_decl
> +{
> +  int t1[sizeof width_bytes / sizeof width_bytes[0] - N_SIZE_SPECS];
> +  int t2[N_SIZE_SPECS - sizeof width_bytes / sizeof width_bytes[0]];
> +};
> +

I like the idea of verifying that the code is consistent.  But the above
structure assumes that zero-length arrays are valid, and they are not in
standard C (at least not in C90, I suppose C99 could have added that?).

As an alternative, you could have an N_WIDTH_BYTES entry at the end of the
width_bytes array, and then have something like:

#error Array size mismatch

Eric Backus
R&D Design Engineer
Agilent Technologies, Inc.
425-335-2495 Tel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]