This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Define CLOCKS_PER_SEC type to the type clock_t


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]