From: groepaz (groepaz_at_gmx.net)
Date: 2002-07-27 23:23:45
Hello Ullrich, Saturday, July 27, 2002, 9:16:03 AM, you wrote: while brosing throug a couple of standard references (bzw can you suggest some decent url? ;=P too much outdated and/or unconfirmed stuff around it seems ;=P) i noticed the following.... "Note that assert must expand to a void expression, so the more obvious if-statement does not suffice as a definition of assert." thus, #undef assert #ifdef NDEBUG # define assert(expr) #else extern void _afailed (const char*, unsigned); # define assert(expr) if ((expr) == 0) _afailed (__FILE__, __LINE__) #endif should be rewritten like #undef assert #ifdef NDEBUG # define assert(expr) ((void) 0) #else extern void _afailed (const char*, unsigned); # define assert(expr) ( (expr)? (void)0 : _afailed (__FILE__, __LINE__) ) #endif mmmmh this dont work with with cc65 however ;=P doesnt it like zero-sized void objects? ;=P oh...and speaking of assert, i had wondered about a different thing aswell.... in the "small" source there are a lof sanity checks in the form assert((sizeof(char)==1); that is, the expression passed to assert is actually constant, can be computed at compile-time, and is true - ultimativly resulting in an "unreachable code" warning for each of those assertions that doesnt fail. hrm, now the question is, is there a way to get rid of these warnings without disabling the specific warning completely? (there might be other places in the code were this warning is triggered not by assertions) ... i actually think the above macro should result into this behaviour...mmmh anyway...reallyreallyreally gotta stop starting new things and fix up what i got ;=P -- Best regards, groepaz mailto:groepaz_at_gmx.net ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2002-07-27 23:23:59 CEST