0002-assert.c - scc - simple c99 compiler
(HTM) git clone git://git.simple-cc.org/scc
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
0002-assert.c (471B)
---
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 0002-assert.c:32: assertion failed 'sizeof(i) < sizeof(c)'
11 end:
12 */
13
14 void
15 handler(int dummy)
16 {
17 _Exit(0);
18 }
19
20 int
21 main()
22 {
23 int i;
24 char c;
25
26 assert(signal(SIGABRT, handler) != SIG_ERR);
27
28 printf("First assert\n");
29 assert(sizeof(i) >= sizeof(c));
30
31 printf("Second assert, that must fail\n");
32 assert(sizeof(i) < sizeof(c));
33
34 return 0;
35 }