File: n_vargs.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 (28 lines) | stat: -rw-r--r-- 1,434 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
/* n_vargs.c:   Macro of variable arguments */
/* from C99 Standard 6.10.3 Examples    */
    #define debug( ...) fprintf( stderr, __VA_ARGS__)
    #define showlist( ...)  puts( #__VA_ARGS__)
    #define report( test, ...)  ((test) ? puts( #test)  \
            : printf( __VA_ARGS__))
    {
        /* fprintf( stderr, "Flag");    */
    debug( "Flag");
        /* fprintf( stderr, "X = %d\n", x);     */
    debug( "X = %d\n", x);
        /* puts( "The first, second, and third items.");   */
    showlist( The first, second, and third items.);
        /* ((x>y) ? puts( "x>y") : printf( "x is %d but y is %d", x, y));   */
    report( x>y, "x is %d but y is %d", x, y);
    }

/* { dg-do preprocess }
   { dg-options "-std=c99" }
   { dg-final { if ![file exist n_vargs.i] { return }                   } }
   { dg-final { if \{ [grep n_vargs.i "fprintf\\( stderr, *\"Flag\" *\\)"] != ""    \} \{   } }
   { dg-final { if \{ [grep n_vargs.i "fprintf\\( stderr, *\"X = %d\\\\n\", x *\\)"] != ""  \} \{   } }
   { dg-final { if \{ [grep n_vargs.i "puts\\( \"The first, second, and third items\.\" *\\)"] != ""  \} \{   } }
   { dg-final { if \{ [grep n_vargs.i "\\(\\( *x>y *\\) \[?\] puts\\( \"x>y\" *\\) : printf\\( *\"x is %d but y is %d\", x, y *\\)\\)"] != "" \} \{   } }
   { dg-final { return \} \} \} \}                                      } }
   { dg-final { fail "n_vargs.c: macro of variable arguments"           } }
 */