File: n_18.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 (33 lines) | stat: -rw-r--r-- 728 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
/* n_18.c:  #define directive.  */

#include    "defs.h"

main( void)
{
    int     c = 3;

/* Excerpts from ISO C 6.8.3 "Examples".    */
#define OBJ_LIKE        (1-1)
#define FTN_LIKE(a)     ( a )

    fputs( "started\n", stderr);

/* 18.1:    Definition of an object-like macro. */
    assert( OBJ_LIKE == 0);
#define ZERO_TOKEN
#ifndef ZERO_TOKEN
    fputs( "Can't define macro to 0-token.\n", stderr);
    exit( 1);
#endif

/* 18.2:    Definition of a function-like macro.    */
    assert( FTN_LIKE( c) == 3);

/* 18.3:    Spelling in string identical to parameter is not a parameter.   */
#define STR( n1, n2)    "n1:n2"
    assert( strcmp( STR( 1, 2), "n1:n2") == 0);

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