File: n_11.c

package info (click to toggle)
mcpp 2.7.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,024 kB
  • ctags: 29,151
  • sloc: ansic: 35,191; sh: 9,231; makefile: 176; cpp: 84; exp: 18
file content (40 lines) | stat: -rw-r--r-- 794 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* n_11.c:  Operator "defined" in #if or #elif directive.   */

#include    "defs.h"

#define MACRO_abc   abc
#define MACRO_0     0
#define ZERO_TOKEN

main( void)
{
    int     abc = 1, a = 0;

    fputs( "started\n", stderr);

/* 11.1:    */
#if     defined a
    assert( a);
#else
    assert( MACRO_abc);
#endif
#if     defined (MACRO_abc)
    assert( MACRO_abc);
#else
    assert( a);
#endif

/* 11.2:    "defined" is an unary operator whose result is 1 or 0.  */
#if     defined MACRO_0 * 3 != 3
    fputs( "Bad handling of defined operator.\n", stderr);
    exit( 1);
#endif
#if     (!defined ZERO_TOKEN != 0) || (-defined ZERO_TOKEN != -1)
    fputs( "Bad grouping of defined, -, ! in #if expression.\n", stderr);
    exit( 1);
#endif

    fputs( "success\n", stderr);
    return  0;
}