We now have compile-time assertions

Andy Lester andy at petdance.com
Fri Mar 23 03:41:14 UTC 2012


I created a new macro PARROT_STATIC_ASSERT(condition) for assertions that can get checked at compile time, for conditions that can be known at compile time.

For example, the first assertion is that sizeof(opcode_t) == sizeof(INTVAL).

    PARROT_STATIC_ASSERT( sizeof(INTVAL) == sizeof(opcode_t) );

If this failed, it would throw out an error like this:

src/global_setup.c: In function ‘init_world’:
src/global_setup.c:184:1: error: size of array ‘static_assertion_at_line_184’ is negative

Let me know if there's anything weird that comes along.

xoxo,
Andy

--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance



More information about the parrot-dev mailing list