1 Jul 2005 01:06
Re: proposal: lib/verify.h
Jim Meyering <jim <at> meyering.net>
2005-06-30 23:06:02 GMT
2005-06-30 23:06:02 GMT
Paul Eggert <eggert <at> CS.UCLA.EDU> wrote:
> Jim Meyering <jim <at> meyering.net> writes:
>
>> #define GL_CONCAT...
>> #define VERIFY(assertion) \
>> struct GL_CONCAT (compile_time_assert_, __LINE__) \
>> { char a[(assertion) ? 1 : -1]; }
>
> This trick won't work if VERIFY is used in two different files with
> the same line number. Typically the problem would occur if there are
> multiple headers that use VERIFY, or a header and a source file that
> both use VERIFY.
That's true, but maybe it won't matter in practice?
All of my uses of the statement-form have ended up being
expanded in .c files.
> Admittedly it's a bit of a pain to have to come up with a name for
> each requirement, as is the case with mktime.c now.
>
> So, how about if we simply dump the named-requirement variant, and
> stick only with the unnamed variant? If there is a need to verify
> stuff at the top level, we can do something like this:
>
> static inline void
> verify_mktime_requirements (void)
> {
> verify (TYPE_IS_INTEGER (time_t));
> verify (TYPE_TWOS_COMPLEMENT (int));
> ...
(Continue reading)
RSS Feed