We now have compile-time assertions

1 view
Skip to first unread message

Andy Lester

unread,
Mar 22, 2012, 11:41:14 PM3/22/12
to parrot-dev Mailing List
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 => an...@petdance.com => www.petdance.com => AIM:petdance

_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev

Reply all
Reply to author
Forward
0 new messages