File: n_25.t

package info (click to toggle)
mcpp 2.7.2-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 8,152 kB
  • ctags: 29,136
  • sloc: ansic: 35,238; sh: 9,241; makefile: 176; cpp: 84; exp: 18
file content (35 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download | duplicates (7)
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
/* n_25.t:  Macro arguments are pre-expanded (unless the argument is an
    operand of # or ## operator) separately, that is, are macro-replaced
    completely prior to rescanning. */

#define MACRO_0         0
#define MACRO_1         1
#define ZERO_TOKEN
#define TWO_ARGS        a,b
#define sub( x, y)      (x - y)
#define glue( a, b)     a ## b
#define xglue( a, b)    glue( a, b)
#define str( a)         # a

/* 25.1:    "TWO_ARGS" is read as one argument to "sub" then expanded to
        "a,b", then "x" is substituted by "a,b".    */
/*  (a,b - 1);  */
    sub( TWO_ARGS, 1);

/* 25.2:    An argument pre-expanded to 0-token.    */
/*  ( - 1); */
    sub( ZERO_TOKEN, 1);

/* 25.3:    "glue( a, b)" is pre-expanded.  */
/*  abc;    */
    xglue( glue( a, b), c);

/* 25.4:    Operands of ## operator are not pre-expanded.   */
/*  MACRO_0MACRO_1; */
    glue( MACRO_0, MACRO_1);

/* 25.5:    Operand of # operator is not pre-expanded.  */
/*  "ZERO_TOKEN";   */
#define ZERO_TOKEN
    str( ZERO_TOKEN);