preprocess.cxx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. #include <preprocess.h>
  2. #include FILE_PATH
  3. #include TARGET_PATH
  4. #include <stdio.h>
  5. #include <string.h>
  6. extern "C" int check_defines_C(void);
  7. int check_defines_CXX()
  8. {
  9. int result = 1;
  10. if (strcmp(FILE_STRING, STRING_VALUE) != 0) {
  11. fprintf(stderr, "FILE_STRING has wrong value in CXX [%s]\n", FILE_STRING);
  12. result = 0;
  13. }
  14. if (strcmp(TARGET_STRING, STRING_VALUE) != 0) {
  15. fprintf(stderr, "TARGET_STRING has wrong value in CXX [%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 CXX [%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 CXX [%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 CXX\n");
  37. result = 0;
  38. }
  39. #endif
  40. #ifdef TARGET_DEF_DEBUG
  41. {
  42. fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in CXX\n");
  43. result = 0;
  44. }
  45. #endif
  46. #ifdef DIRECTORY_DEF_DEBUG
  47. {
  48. fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in CXX\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 CXX\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 CXX\n");
  63. result = 0;
  64. }
  65. #endif
  66. #ifndef DIRECTORY_DEF_RELEASE
  67. {
  68. fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in CXX\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 CXX\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 CXX\n");
  85. result = 0;
  86. }
  87. #endif
  88. #ifndef DIRECTORY_DEF_DEBUG
  89. {
  90. fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in CXX\n");
  91. result = 0;
  92. }
  93. #endif
  94. #ifdef FILE_DEF_RELEASE
  95. {
  96. fprintf(stderr, "FILE_DEF_RELEASE should not be defined in CXX\n");
  97. result = 0;
  98. }
  99. #endif
  100. #ifdef TARGET_DEF_RELEASE
  101. {
  102. fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in CXX\n");
  103. result = 0;
  104. }
  105. #endif
  106. #ifdef DIRECTORY_DEF_RELEASE
  107. {
  108. fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in CXX\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,
  118. "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in CXX\n");
  119. result = 0;
  120. }
  121. #endif
  122. #endif
  123. #if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
  124. {
  125. fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in CXX\n");
  126. result = 0;
  127. }
  128. #endif
  129. #endif
  130. #if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
  131. #if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
  132. #ifndef PREPROCESS_XCODE
  133. {
  134. fprintf(stderr,
  135. "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in CXX\n");
  136. result = 0;
  137. }
  138. #endif
  139. #endif
  140. #if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
  141. {
  142. fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in CXX\n");
  143. result = 0;
  144. }
  145. #endif
  146. #endif
  147. #ifndef FILE_PATH_DEF
  148. {
  149. fprintf(stderr, "FILE_PATH_DEF not defined in CXX\n");
  150. result = 0;
  151. }
  152. #endif
  153. #ifndef TARGET_PATH_DEF
  154. {
  155. fprintf(stderr, "TARGET_PATH_DEF not defined in CXX\n");
  156. result = 0;
  157. }
  158. #endif
  159. #ifndef FILE_DEF
  160. {
  161. fprintf(stderr, "FILE_DEF not defined in CXX\n");
  162. result = 0;
  163. }
  164. #endif
  165. #ifndef TARGET_DEF
  166. {
  167. fprintf(stderr, "TARGET_DEF not defined in CXX\n");
  168. result = 0;
  169. }
  170. #endif
  171. #ifndef DIRECTORY_DEF
  172. {
  173. fprintf(stderr, "DIRECTORY_DEF not defined in CXX\n");
  174. result = 0;
  175. }
  176. #endif
  177. #ifndef OLD_DEF
  178. {
  179. fprintf(stderr, "OLD_DEF not defined in CXX\n");
  180. result = 0;
  181. }
  182. #endif
  183. #if !defined(OLD_EXPR) || OLD_EXPR != 2
  184. {
  185. fprintf(stderr, "OLD_EXPR id not work in C [%s]\n", TO_STRING(OLD_EXPR));
  186. result = 0;
  187. }
  188. #endif
  189. return result;
  190. }
  191. int main()
  192. {
  193. int result = 1;
  194. if (!check_defines_C()) {
  195. result = 0;
  196. }
  197. if (!check_defines_CXX()) {
  198. result = 0;
  199. }
  200. if (result) {
  201. printf("All preprocessor definitions are correct.\n");
  202. return 0;
  203. } else {
  204. return 1;
  205. }
  206. }