This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Define CLOCKS_PER_SEC type to the type clock_t
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 05 Jan 2015 20:47:35 -0800
- Subject: Re: [PATCH] Define CLOCKS_PER_SEC type to the type clock_t
- Authentication-results: sourceware.org; auth=none
- References: <20150105204653 dot GA31001 at intel dot com> <54AB1115 dot 80608 at cs dot ucla dot edu> <CAMe9rOrExjqKKFUkjcN+4SzzouGQ7yyq8RnfWxKmotEaQ6aZRQ at mail dot gmail dot com> <CAMe9rOpBRqzqwhefrKG9eZro8qXwRBc=+-WT5Wx4xbNMzJJ3fg at mail dot gmail dot com> <CAMe9rOoZPZAfWt_jfci2XOhPcJde09mOz8RtCs_6S1dqU5OzqA at mail dot gmail dot com> <54AB2185 dot 2060402 at cs dot ucla dot edu> <CAMe9rOrpk5vHFjL=EFNByhwBSj34zYFc7+YyfyCUt8JJjD0idw at mail dot gmail dot com>
H.J. Lu wrote:
assert (CLOCKS_PER_SEC == 1000000l);
This fails only at runtime if the value is wrong, which is not as good as
checking it at compile-time. Something like this, perhaps:
#if __STDC_VERSION__ < 201112L
# define _Static_assert(e, s) extern int (*static_assert_checker (void)) \
[sizeof (struct { unsigned int error_if_negative: (e) ? 1 : -1; })]
#endif
#define verify(e) _Static_assert (e, "verify (" #e ")")
and then use 'verify' instead of 'assert'.
Also, there's no need for the trailing 'l' here.