summaryrefslogtreecommitdiffstats
path: root/Tests/Preprocess/preprocess.c
blob: b3117da5f3653c2eca2f960992c4f96a0d5355b4 (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#include <preprocess.h>

#include FILE_PATH
#include TARGET_PATH

#include <stdio.h>
#include <string.h>

int check_defines_C(void)
{
  int result = 1;
  if (strcmp(FILE_STRING, STRING_VALUE) != 0) {
    fprintf(stderr, "FILE_STRING has wrong value in C [%s] vs [%s]\n",
            FILE_STRING, STRING_VALUE);
    result = 0;
  }
  if (strcmp(TARGET_STRING, STRING_VALUE) != 0) {
    fprintf(stderr, "TARGET_STRING has wrong value in C [%s] vs [%s]\n",
            TARGET_STRING, STRING_VALUE);
    result = 0;
  }
  {
    int x = 2;
    int y = 3;
    if ((FILE_EXPR) != (EXPR)) {
      fprintf(stderr, "FILE_EXPR did not work in C [%s] vs [%s]\n",
              TO_STRING(FILE_EXPR), TO_STRING(EXPR));
      result = 0;
    }
    if ((TARGET_EXPR) != (EXPR)) {
      fprintf(stderr, "TARGET_EXPR did not work in C [%s] vs [%s]\n",
              TO_STRING(TARGET_EXPR), TO_STRING(EXPR));
      result = 0;
    }
  }
#ifdef NDEBUG
#  ifdef FILE_DEF_DEBUG
  {
    fprintf(stderr, "FILE_DEF_DEBUG should not be defined in C\n");
    result = 0;
  }
#  endif
#  ifdef TARGET_DEF_DEBUG
  {
    fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in C\n");
    result = 0;
  }
#  endif
#  ifdef DIRECTORY_DEF_DEBUG
  {
    fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in C\n");
    result = 0;
  }
#  endif
#  ifndef FILE_DEF_RELEASE
#    ifndef PREPROCESS_XCODE
  {
    fprintf(stderr, "FILE_DEF_RELEASE should be defined in C\n");
    result = 0;
  }
#    endif
#  endif
#  ifndef TARGET_DEF_RELEASE
  {
    fprintf(stderr, "TARGET_DEF_RELEASE should be defined in C\n");
    result = 0;
  }
#  endif
#  ifndef DIRECTORY_DEF_RELEASE
  {
    fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in C\n");
    result = 0;
  }
#  endif
#endif
#ifdef PREPROCESS_DEBUG
#  ifndef FILE_DEF_DEBUG
#    ifndef PREPROCESS_XCODE
  {
    fprintf(stderr, "FILE_DEF_DEBUG should be defined in C\n");
    result = 0;
  }
#    endif
#  endif
#  ifndef TARGET_DEF_DEBUG
  {
    fprintf(stderr, "TARGET_DEF_DEBUG should be defined in C\n");
    result = 0;
  }
#  endif
#  ifndef DIRECTORY_DEF_DEBUG
  {
    fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in C\n");
    result = 0;
  }
#  endif
#  ifdef FILE_DEF_RELEASE
  {
    fprintf(stderr, "FILE_DEF_RELEASE should not be defined in C\n");
    result = 0;
  }
#  endif
#  ifdef TARGET_DEF_RELEASE
  {
    fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in C\n");
    result = 0;
  }
#  endif
#  ifdef DIRECTORY_DEF_RELEASE
  {
    fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in C\n");
    result = 0;
  }
#  endif
#endif
#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
#  if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG)
#    ifndef PREPROCESS_XCODE
  {
    fprintf(stderr, "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in C\n");
    result = 0;
  }
#    endif
#  endif
#  if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
  {
    fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in C\n");
    result = 0;
  }
#  endif
#endif
#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
#  if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
#    ifndef PREPROCESS_XCODE
  {
    fprintf(stderr,
            "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in C\n");
    result = 0;
  }
#    endif
#  endif
#  if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
  {
    fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in C\n");
    result = 0;
  }
#  endif
#endif
#ifndef FILE_PATH_DEF
  {
    fprintf(stderr, "FILE_PATH_DEF not defined in C\n");
    result = 0;
  }
#endif
#ifndef TARGET_PATH_DEF
  {
    fprintf(stderr, "TARGET_PATH_DEF not defined in C\n");
    result = 0;
  }
#endif
#ifndef FILE_DEF
  {
    fprintf(stderr, "FILE_DEF not defined in C\n");
    result = 0;
  }
#endif
#ifndef TARGET_DEF
  {
    fprintf(stderr, "TARGET_DEF not defined in C\n");
    result = 0;
  }
#endif
#ifndef DIRECTORY_DEF
  {
    fprintf(stderr, "DIRECTORY_DEF not defined in C\n");
    result = 0;
  }
#endif
#ifndef OLD_DEF
  {
    fprintf(stderr, "OLD_DEF not defined in C\n");
    result = 0;
  }
#endif
#if !defined(OLD_EXPR) || OLD_EXPR != 2
  {
    fprintf(stderr, "OLD_EXPR id not work in C [%s]\n", TO_STRING(OLD_EXPR));
    result = 0;
  }
#endif
  return result;
}