1 /* 2 * Test header file for h2ph 3 * 4 * Try to test as many constructs as possible 5 * For example, the multi-line comment :) 6 */ 7 8 /* And here's a single line comment :) */ 9 10 /* Test #define with no indenting, over multiple lines */ 11 #define SQUARE(x) \ 12 ((x)*(x)) 13 14 /* Test #ifndef and parameter interpretation*/ 15 #ifndef ERROR 16 #define ERROR(x) fprintf(stderr, "%s\n", x[2][3][0]) 17 #endif /* ERROR */ 18 19 #ifndef _H2PH_H_ 20 #define _H2PH_H_ 21 22 /* #ident - doesn't really do anything, but I think it always gets included anyway */ 23 #ident "$Revision h2ph.h,v 1.0 98/05/04 20:42:14 billy $" 24 25 /* Test #undef */ 26 #undef MAX 27 #define MAX(a,b) ((a) > (b) ? (a) : (b)) 28 29 /* Test #undef'ining an existing constant function */ 30 #define NOTTRUE 0 31 #undef NOTTRUE 32 33 /* Test #ifdef */ 34 #ifdef __SOME_UNIMPORTANT_PROPERTY 35 #define MIN(a,b) ((a) < (b) ? (a) : (b)) 36 #endif /* __SOME_UNIMPORTANT_PROPERTY */ 37 38 /* 39 * Test #if, #elif, #else, #endif, #warn and #error, and '!' 40 * Also test whitespace between the '#' and the command 41 */ 42 #if !(defined __SOMETHING_MORE_IMPORTANT) 43 # warn Be careful... 44 #elif !(defined __SOMETHING_REALLY_REALLY_IMPORTANT) 45 # error "Nup, can't go on" /* ' /* stupid font-lock-mode */ 46 #else /* defined __SOMETHING_MORE_IMPORTANT && defined __SOMETHING_REALLY_REALLY_IMPORTANT */ 47 # define EVERYTHING_IS_OK 48 #endif 49 50 /* Test && and || */ 51 #undef WHATEVER 52 #if (!((defined __SOMETHING_TRIVIAL && defined __SOMETHING_LESS_SO)) \ 53 || defined __SOMETHING_OVERPOWERING) 54 # define WHATEVER 6 55 #elif !(defined __SOMETHING_TRIVIAL) /* defined __SOMETHING_LESS_SO */ 56 # define WHATEVER 7 57 #elif !(defined __SOMETHING_LESS_SO) /* defined __SOMETHING_TRIVIAL */ 58 # define WHATEVER 8 59 #else /* defined __SOMETHING_TRIVIAL && defined __SOMETHING_LESS_SO */ 60 # define WHATEVER 1000 61 #endif 62 63 /* Test passing through the alien constructs (perlbug #34493) */ 64 #ifdef __LANGUAGE_PASCAL__ 65 function Tru64_Pascal(n: Integer): Integer; 66 #endif 67 68 /* 69 * Test #include, #import and #include_next 70 * #include_next is difficult to test, it really depends on the actual 71 * circumstances - for example, '#include_next <limits.h>' on a Linux system 72 * with 'use lib qw(/opt/perl5/lib/site_perl/i586-linux/linux);' or whatever 73 * your equivalent is... 74 */ 75 #if 0 76 #include <sys/socket.h> 77 #import "sys/ioctl.h" 78 #include_next <sys/fcntl.h> 79 #endif 80 81 /* typedefs should be ignored */ 82 typedef struct a_struct { 83 int typedefs_should; 84 char be_ignored; 85 long as_well; 86 } a_typedef; 87 88 /* 89 * however, typedefs of enums and just plain enums should end up being treated 90 * like a bunch of #defines... 91 */ 92 93 typedef enum _days_of_week { sun, mon, tue, wed, thu, fri, sat, Sun=0, Mon, 94 Tue, Wed, Thu, Fri, Sat } days_of_week; 95 96 /* 97 * Some moderate flexing of tri-graph pre substitution. 98 */ 99 ??=ifndef _SOMETHING_TRIGRAPHIC 100 ??=define _SOMETHING_TRIGRAPHIC 101 ??= define SOMETHING_ELSE_TRIGRAPHIC_0 "??!" /* | ??!| || */ 102 ??=define SOMETHING_ELSE_TRIGRAPHIC_1 "??'" /* | ??'| ^| */ 103 ??= define SOMETHING_ELSE_TRIGRAPHIC_2 "??(" /* | ??(| [| */ 104 ??= define SOMETHING_ELSE_TRIGRAPHIC_3 "??)" /* | ??)| ]| */ 105 ??=define SOMETHING_ELSE_TRIGRAPHIC_4 "??-0" /* | ??-| ~| */ 106 ??= define SOMETHING_ELSE_TRIGRAPHIC_5 "??/ " /* | ??/| \| */ 107 ??= define SOMETHING_ELSE_TRIGRAPHIC_6 "??<" /* | ??<| {| */ 108 ??=define SOMETHING_ELSE_TRIGRAPHIC_7 "??=" /* | ??=| #| */ 109 ??= define SOMETHING_ELSE_TRIGRAPHIC_8 "??>" /* | ??>| }| */ 110 ??=endif 111 112 // test C++-style comment 113 114 #if 1 115 typdef struct empty_struct { 116 } // trailing C++-style comment should not force continuation 117 #endif 118 119 /* comments (that look like string) inside enums... */ 120 121 enum { 122 /* foo; 123 can't 124 */ 125 }; 126 127 enum flimflam { 128 flim, 129 /* foo; 130 can't 131 */ 132 flam 133 } flamflim; 134 135 static __inline__ int blli_in_use(struct atm_blli blli) 136 { 137 return blli.l2_proto || blli.l3_proto; 138 } 139 140 /* Handle multi-line quoted strings: */ 141 __asm__ __volatile__(" 142 this 143 produces 144 no 145 output 146 "); 147 148 #define multiline "multiline 149 string" 150 151 #endif /* _H2PH_H_ */ 152