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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
program preprocessor6
! Nested macros
implicit none
#define X 5
#define Y
#ifdef X
# ifdef Y
print *, "1a"
# else
print *, "1b"
# endif
#else
# ifdef Y
print *, "2a"
# else
print *, "2b"
# endif
#endif
#ifdef X
# ifdef Z
print *, "1a"
# else
print *, "1b"
# endif
#else
# ifdef Z
print *, "2a"
# else
print *, "2b"
# endif
#endif
#ifdef Z
# ifdef Y
print *, "1a"
# else
print *, "1b"
# endif
#else
# ifdef Y
print *, "2a"
# else
print *, "2b"
# endif
#endif
#ifdef Z
# ifdef Z
print *, "1a"
# else
print *, "1b"
# endif
#else
# ifdef Z
print *, "2a"
# else
print *, "2b"
# endif
#endif
! ifndef
#ifdef X
# ifndef Y
print *, "1a"
# else
print *, "1b"
# endif
#else
# ifndef Y
print *, "2a"
# else
print *, "2b"
# endif
#endif
! more nesting
#ifdef X
print *, "10"
# ifdef Y
print *, "1a0"
# ifdef Z
print *, "1aa"
# else
print *, "1ab"
# endif
print *, "1ac"
# else
print *, "1b"
# endif
print *, "1c"
#else
print *, "20"
# ifdef Y
print *, "20"
# ifdef Z
print *, "2aa"
# else
print *, "2ab"
# endif
print *, "2a"
# else
print *, "2b"
# endif
print *, "2c"
#endif
#ifdef X
print *, "10"
# ifdef Y
print *, "1a0"
# ifdef X
print *, "1aa"
# else
print *, "1ab"
# endif
print *, "1ac"
# endif
print *, "1c"
#endif
end program
|