1#include <stdio.h> 2 3#define SPLICE(a, b) INNER_SPLICE(a, b) 4#define INNER_SPLICE(a, b) a ## b 5#define STRINGIFY(a) INNER_STRINGIFY(a) 6#define INNER_STRINGIFY(a) #a 7 8#define FIFTY_SEVEN 57 9 10#define FORTY_EIGHT 48 11#undef FORTY_EIGHT 12 13struct outer 14{ 15 struct fields 16 { 17 struct fault 18 { 19 int addr; 20 } fault; 21 } fields; 22}; 23struct outer address; 24 25#define addr fields.fault.addr 26 27/* A macro named UNTIL_<func> is #defined until just before the 28 definition of the function <func>. 29 30 A macro named BEFORE_<func> is not #defined until just before the 31 definition of <func>. 32 33 The macro WHERE is redefined before each function <func> to the 34 token list ``before <func>''. 35 36 The macscp IN_MACSCP2_H and IN_MACSCP3_H are defined while 37 processing those header files; macscp4.h uses them to choose 38 appropriate function names, output strings, and macro definitions. */ 39 40#define UNTIL_MACSCP1_1 41#define UNTIL_MACSCP2_1 42#define UNTIL_MACSCP4_1_FROM_MACSCP2 43#define UNTIL_MACSCP4_2_FROM_MACSCP2 44#define UNTIL_MACSCP2_2 45#define UNTIL_MACSCP1_2 46#define UNTIL_MACSCP3_1 47#define UNTIL_MACSCP4_1_FROM_MACSCP3 48#define UNTIL_MACSCP4_2_FROM_MACSCP3 49#define UNTIL_MACSCP3_2 50#define UNTIL_MACSCP1_3 51 52#define WHERE before macscp1_1 53#define BEFORE_MACSCP1_1 54#undef UNTIL_MACSCP1_1 55void 56macscp1_1 () 57{ 58 puts ("macscp1_1"); 59} 60 61#include "macscp2.h" 62 63#undef WHERE 64#define WHERE before macscp1_2 65#define BEFORE_MACSCP1_2 66#undef UNTIL_MACSCP1_2 67void 68macscp1_2 () 69{ 70 puts ("macscp1_2"); 71} 72 73#include "macscp3.h" 74 75#undef WHERE 76#define WHERE before macscp1_3 77#define BEFORE_MACSCP1_3 78#undef UNTIL_MACSCP1_3 79void 80macscp1_3 () 81{ 82 puts ("macscp1_3"); 83} 84 85void 86macscp_expr (void) 87{ 88 int foo = -1; 89 90 foo = 0; /* set breakpoint here */ 91#define MACRO_TO_EXPAND foo 92 foo = 1; 93#undef MACRO_TO_EXPAND 94 foo = 2; 95} 96 97#define TWENTY_THREE 23 98 99int 100main (int argc, char **argv) 101{ 102 macscp1_1 (); 103 macscp2_1 (); 104 macscp4_1_from_macscp2 (); 105 macscp4_2_from_macscp2 (); 106 macscp2_2 (); 107 macscp1_2 (); 108 macscp3_1 (); 109 macscp4_1_from_macscp3 (); 110 macscp4_2_from_macscp3 (); 111 macscp3_2 (); 112 macscp1_3 (); 113 macscp_expr (); 114} 115