scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

0002-assert.c (412B)


      1 #include <assert.h>
      2 #include <signal.h>
      3 #include <stdio.h>
      4 #include <stdlib.h>
      5 
      6 /*
      7 output:
      8 First assert
      9 Second assert, that must fail
     10 end:
     11 */
     12 
     13 void
     14 handler(int dummy)
     15 {
     16 	_Exit(0);
     17 }
     18 
     19 int
     20 main()
     21 {
     22 	int i;
     23 	char c;
     24 
     25 	assert(signal(SIGABRT, handler) != SIG_ERR);
     26 
     27 	printf("First assert\n");
     28 	assert(sizeof(i) >= sizeof(c));
     29 
     30 	printf("Second assert, that must fail\n");
     31 	assert(sizeof(i) < sizeof(c));
     32 
     33 	return 0;
     34 }