C preprocessor: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Line 20:
==== Uses for debugging ====
Assertions are used to catch situations which should never happen, even under error circumstances.
#define assert(condition) do { if (!(xcondition)) { complain("assertion fail (" #condition ")"); panic(); } } while(0)
assert( sizeof(struct free_memory_block) == 8 );
assert( 1 != 2 );
Line 27:
#define assert(x) do {} while(0)
Some rare unrecoverable errors should be tested for also in production code and these test should not be disabled so that we recognise the problem instead of having random crashes
#define testif(condition) do { if (!(xcondition)) { complain("testif fail (" #condition ")" ); panic(); } } while(0)
testif( isChecksumCorrect( kernel_heap.first_free_list ) );
testif( timersAreOn );
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu