preprocess.cxx 4.4 KB

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