Paul Eggert wrote: > A student pointed out You really tortured your students with this beast?! :-)
> that Boost has a BOOST_STATIC_ASSERT(x) macro > that acts like verify(x) but is defined in a much more-complicated > way. See <http://boost.org/boost/static_assert.hpp>. Boost's version > has special cases for GCC, for MSVC, for SGI MIPSpro, etc., ,etc. > > <verify.h> was originally designed for C, but I had thought that it > would work for C++ compilers too. Is there some reason that a C++ > implementation would need all that extra complexity to support > <verify.h> properly, or am I missing something? The current verify.h doesn't work with C++ - error "types may not be defined in 'sizeof' expressions". Find appended a fix, tested with g++ 3.2.2 and 4.0.1. Programming C++ was a big mess of #ifdefs until ca, 2000, when the Boost code was written. Nowadays the support for template parameters in most compilers is much better. This means, there can be another compiler which, maybe, doesn't grok template parameters as bit field width, or the use of a conditional expression in a template. But it will probably not be more than one compiler. Bruno 2005-10-04 Bruno Haible <[EMAIL PROTECTED]> * verify.h (verify_true): Provide alternative definition for C++. *** verify.h 27 Sep 2005 05:36:30 -0000 1.6 --- verify.h 4 Oct 2005 20:07:19 -0000 *************** *** 36,44 **** /* Verify requirement R at compile-time, as an integer constant expression. Return true. */ ! # define verify_true(R) \ ! (!!sizeof \ ! (struct { unsigned int verify_error_if_negative_size__ : (R) ? 1 : -1; })) /* Verify requirement R at compile-time, as a declaration without a trailing ';'. */ --- 36,51 ---- /* Verify requirement R at compile-time, as an integer constant expression. Return true. */ ! # ifdef __cplusplus ! template <int w> ! struct verify_type__ { unsigned int verify_error_if_negative_size__ : w; }; ! # define verify_true(R) \ ! (!!sizeof (verify_type__<(R) ? 1 : -1>)) ! # else ! # define verify_true(R) \ ! (!!sizeof \ ! (struct { unsigned int verify_error_if_negative_size__ : (R) ? 1 : -1; })) ! # endif /* Verify requirement R at compile-time, as a declaration without a trailing ';'. */ _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib