preprocess.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #include <preprocess.h>
  2. #include FILE_PATH
  3. #include TARGET_PATH
  4. #include <stdio.h>
  5. #include <string.h>
  6. int check_defines_C(void)
  7. {
  8. int result = 1;
  9. if (strcmp(FILE_STRING, STRING_VALUE) != 0) {
  10. fprintf(stderr, "FILE_STRING has wrong value in C [%s] vs [%s]\n",
  11. FILE_STRING, STRING_VALUE);
  12. result = 0;
  13. }
  14. if (strcmp(TARGET_STRING, STRING_VALUE) != 0) {
  15. fprintf(stderr, "TARGET_STRING has wrong value in C [%s]\n",
  16. TARGET_STRING);
  17. result = 0;
  18. }
  19. {
  20. int x = 2;
  21. int y = 3;
  22. if ((FILE_EXPR) != (EXPR)) {
  23. fprintf(stderr, "FILE_EXPR did not work in C [%s]\n",
  24. TO_STRING(FILE_EXPR));
  25. result = 0;
  26. }
  27. if ((TARGET_EXPR) != (EXPR)) {
  28. fprintf(stderr, "TARGET_EXPR did not work in C [%s]\n",
  29. TO_STRING(FILE_EXPR));
  30. result = 0;
  31. }
  32. }
  33. #ifdef NDEBUG
  34. # ifdef FILE_DEF_DEBUG
  35. {
  36. fprintf(stderr, "FILE_DEF_DEBUG should not be defined in C\n");
  37. result = 0;
  38. }
  39. # endif
  40. # ifdef TARGET_DEF_DEBUG
  41. {
  42. fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in C\n");
  43. result = 0;
  44. }
  45. # endif
  46. # ifdef DIRECTORY_DEF_DEBUG
  47. {
  48. fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in C\n");
  49. result = 0;
  50. }
  51. # endif
  52. # ifndef FILE_DEF_RELEASE
  53. # ifndef PREPROCESS_XCODE
  54. {
  55. fprintf(stderr, "FILE_DEF_RELEASE should be defined in C\n");
  56. result = 0;
  57. }
  58. # endif
  59. # endif
  60. # ifndef TARGET_DEF_RELEASE
  61. {
  62. fprintf(stderr, "TARGET_DEF_RELEASE should be defined in C\n");
  63. result = 0;
  64. }
  65. # endif
  66. # ifndef DIRECTORY_DEF_RELEASE
  67. {
  68. fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in C\n");
  69. result = 0;
  70. }
  71. # endif
  72. #endif
  73. #ifdef PREPROCESS_DEBUG
  74. # ifndef FILE_DEF_DEBUG
  75. # ifndef PREPROCESS_XCODE
  76. {
  77. fprintf(stderr, "FILE_DEF_DEBUG should be defined in C\n");
  78. result = 0;
  79. }
  80. # endif
  81. # endif
  82. # ifndef TARGET_DEF_DEBUG
  83. {
  84. fprintf(stderr, "TARGET_DEF_DEBUG should be defined in C\n");
  85. result = 0;
  86. }
  87. # endif
  88. # ifndef DIRECTORY_DEF_DEBUG
  89. {
  90. fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in C\n");
  91. result = 0;
  92. }
  93. # endif
  94. # ifdef FILE_DEF_RELEASE
  95. {
  96. fprintf(stderr, "FILE_DEF_RELEASE should not be defined in C\n");
  97. result = 0;
  98. }
  99. # endif
  100. # ifdef TARGET_DEF_RELEASE
  101. {
  102. fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in C\n");
  103. result = 0;
  104. }
  105. # endif
  106. # ifdef DIRECTORY_DEF_RELEASE
  107. {
  108. fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in C\n");
  109. result = 0;
  110. }
  111. # endif
  112. #endif
  113. #if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
  114. # if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG)
  115. # ifndef PREPROCESS_XCODE
  116. {
  117. fprintf(stderr, "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in C\n");
  118. result = 0;
  119. }
  120. # endif
  121. # endif
  122. # if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
  123. {
  124. fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in C\n");
  125. result = 0;
  126. }
  127. # endif
  128. #endif
  129. #if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
  130. # if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
  131. # ifndef PREPROCESS_XCODE
  132. {
  133. fprintf(stderr,
  134. "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in C\n");
  135. result = 0;
  136. }
  137. # endif
  138. # endif
  139. # if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
  140. {
  141. fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in C\n");
  142. result = 0;
  143. }
  144. # endif
  145. #endif
  146. #ifndef FILE_PATH_DEF
  147. {
  148. fprintf(stderr, "FILE_PATH_DEF not defined in C\n");
  149. result = 0;
  150. }
  151. #endif
  152. #ifndef TARGET_PATH_DEF
  153. {
  154. fprintf(stderr, "TARGET_PATH_DEF not defined in C\n");
  155. result = 0;
  156. }
  157. #endif
  158. #ifndef FILE_DEF
  159. {
  160. fprintf(stderr, "FILE_DEF not defined in C\n");
  161. result = 0;
  162. }
  163. #endif
  164. #ifndef TARGET_DEF
  165. {
  166. fprintf(stderr, "TARGET_DEF not defined in C\n");
  167. result = 0;
  168. }
  169. #endif
  170. #ifndef DIRECTORY_DEF
  171. {
  172. fprintf(stderr, "DIRECTORY_DEF not defined in C\n");
  173. result = 0;
  174. }
  175. #endif
  176. #ifndef OLD_DEF
  177. {
  178. fprintf(stderr, "OLD_DEF not defined in C\n");
  179. result = 0;
  180. }
  181. #endif
  182. #if !defined(OLD_EXPR) || OLD_EXPR != 2
  183. {
  184. fprintf(stderr, "OLD_EXPR id not work in C [%s]\n", TO_STRING(OLD_EXPR));
  185. result = 0;
  186. }
  187. #endif
  188. return result;
  189. }