preprocess.cxx 4.4 KB

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