xref: /freebsd/contrib/unifdef/tests/if4-k.c (revision fb3ef04d2028110f06d68b09009f1f2ca0f4128e)
1*fb3ef04dSDag-Erling Smørgrav /* Copyright 2004, 2008 Bob Proulx <bob@proulx.com>
2*fb3ef04dSDag-Erling Smørgrav Distributed under the two-clause BSD licence;
3*fb3ef04dSDag-Erling Smørgrav see the COPYING file for details. */
4*fb3ef04dSDag-Erling Smørgrav 
5*fb3ef04dSDag-Erling Smørgrav #include <stdio.h>
6*fb3ef04dSDag-Erling Smørgrav #include <stdlib.h>
7*fb3ef04dSDag-Erling Smørgrav 
8*fb3ef04dSDag-Erling Smørgrav #if 0
9*fb3ef04dSDag-Erling Smørgrav /* This code is commented out. "#if 0 then" */
10*fb3ef04dSDag-Erling Smørgrav #else
11*fb3ef04dSDag-Erling Smørgrav /* This code is passed through. "#if 0 else" */
12*fb3ef04dSDag-Erling Smørgrav #endif
13*fb3ef04dSDag-Erling Smørgrav 
14*fb3ef04dSDag-Erling Smørgrav #if 1
15*fb3ef04dSDag-Erling Smørgrav /* This code is passed through. "#if 1 then" */
16*fb3ef04dSDag-Erling Smørgrav #else
17*fb3ef04dSDag-Erling Smørgrav /* This code is passed through. "#if 1 else" */
18*fb3ef04dSDag-Erling Smørgrav #endif
19*fb3ef04dSDag-Erling Smørgrav 
20*fb3ef04dSDag-Erling Smørgrav #if defined(FOO) || defined(FOOB)
foo1()21*fb3ef04dSDag-Erling Smørgrav int foo1() { return 0; }
22*fb3ef04dSDag-Erling Smørgrav #else
23*fb3ef04dSDag-Erling Smørgrav #error FOO or FOOB not defined
24*fb3ef04dSDag-Erling Smørgrav #endif
25*fb3ef04dSDag-Erling Smørgrav 
26*fb3ef04dSDag-Erling Smørgrav #if defined(FOOB) || defined(FOO)
foo2()27*fb3ef04dSDag-Erling Smørgrav int foo2() { return 0; }
28*fb3ef04dSDag-Erling Smørgrav #else
29*fb3ef04dSDag-Erling Smørgrav #error FOO or FOOB not defined
30*fb3ef04dSDag-Erling Smørgrav #endif
31*fb3ef04dSDag-Erling Smørgrav 
32*fb3ef04dSDag-Erling Smørgrav #if defined(FOO) && defined(FOOB)
foo3()33*fb3ef04dSDag-Erling Smørgrav int foo3() { return 0; }
34*fb3ef04dSDag-Erling Smørgrav #else
35*fb3ef04dSDag-Erling Smørgrav #error FOO and FOOB not defined
36*fb3ef04dSDag-Erling Smørgrav #endif
37*fb3ef04dSDag-Erling Smørgrav 
38*fb3ef04dSDag-Erling Smørgrav #if defined(FOOB) && defined(FOO)
foo4()39*fb3ef04dSDag-Erling Smørgrav int foo4() { return 0; }
40*fb3ef04dSDag-Erling Smørgrav #else
41*fb3ef04dSDag-Erling Smørgrav #error FOO and FOOB not defined
42*fb3ef04dSDag-Erling Smørgrav #endif
43*fb3ef04dSDag-Erling Smørgrav 
main()44*fb3ef04dSDag-Erling Smørgrav int main()
45*fb3ef04dSDag-Erling Smørgrav {
46*fb3ef04dSDag-Erling Smørgrav   foo1();
47*fb3ef04dSDag-Erling Smørgrav   foo2();
48*fb3ef04dSDag-Erling Smørgrav   foo3();
49*fb3ef04dSDag-Erling Smørgrav   foo4();
50*fb3ef04dSDag-Erling Smørgrav }
51