01: // assert() macro
02: #include <stdio.h>
03: #include <stdlib.h>
04: 
05: // adding a "#define NDEBUG" BEFORE the #include<assert.h> disable all assert() 
06: //#define NDEBUG 
07: #include <assert.h>
08: 
09: int main(int argc, char **argv) {
10:   int x = 7;
11: 
12:   /*  assume that here there is a lot of code, and
13:       that, by mistake, the content of x is changed!
14:       this is a bug if I assume that x is 7.
15:       an assert can easily spot this situation
16:    */
17:   x = 9; // my bug
18: 
19:   // assertion that check the code
20:   assert(x==7);
21: 
22:   /* Rest of the code */
23: 
24:   return 0;
25: }
26: 


Se avete commenti o osservazioni su questa pagina
mandate un messaggio di posta elettronica a bertoƶƶi@ce.unipr.it