xref: /freebsd/contrib/unifdef/tests/if3-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(BAR)
foo()21*fb3ef04dSDag-Erling Smørgrav int foo() { return 0; }
22*fb3ef04dSDag-Erling Smørgrav #else
23*fb3ef04dSDag-Erling Smørgrav #error BAR defined
24*fb3ef04dSDag-Erling Smørgrav #endif
25*fb3ef04dSDag-Erling Smørgrav 
main()26*fb3ef04dSDag-Erling Smørgrav int main()
27*fb3ef04dSDag-Erling Smørgrav {
28*fb3ef04dSDag-Erling Smørgrav   foo();
29*fb3ef04dSDag-Erling Smørgrav }
30