check_config_h.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import sys
  2. data = """
  3. #if defined(SIZEOF_LONG)
  4. static_assert(sizeof(long) == SIZEOF_LONG, "fixme 1");
  5. #endif
  6. #if defined(SIZEOF_PTHREAD_T)
  7. #include <pthread.h>
  8. static_assert(sizeof(pthread_t) == SIZEOF_PTHREAD_T, "fixme 2");
  9. #endif
  10. #if defined(SIZEOF_SIZE_T)
  11. #include <stddef.h>
  12. static_assert(sizeof(size_t) == SIZEOF_SIZE_T, "fixme 3");
  13. #endif
  14. #if defined(SIZEOF_TIME_T)
  15. #include <time.h>
  16. static_assert(sizeof(time_t) == SIZEOF_TIME_T, "fixme 4");
  17. #endif
  18. #if defined(SIZEOF_UINTPTR_T)
  19. #include <stdint.h>
  20. static_assert(sizeof(uintptr_t) == SIZEOF_UINTPTR_T, "fixme 5");
  21. #endif
  22. #if defined(SIZEOF_VOID_P)
  23. static_assert(sizeof(void*) == SIZEOF_VOID_P, "fixme 6");
  24. #endif
  25. #if defined(SIZEOF_FPOS_T)
  26. #include <stdio.h>
  27. static_assert(sizeof(fpos_t) == SIZEOF_FPOS_T, "fixme 7");
  28. #endif
  29. #if defined(SIZEOF_DOUBLE)
  30. static_assert(sizeof(double) == SIZEOF_DOUBLE, "fixme 8");
  31. #endif
  32. #if defined(SIZEOF_LONG_DOUBLE)
  33. static_assert(sizeof(long double) == SIZEOF_LONG_DOUBLE, "fixme 9");
  34. #endif
  35. #if defined(SIZEOF_FLOAT)
  36. static_assert(sizeof(float) == SIZEOF_FLOAT, "fixme 10");
  37. #endif
  38. #if defined(SIZEOF_INT)
  39. static_assert(sizeof(int) == SIZEOF_INT, "fixme 11");
  40. #endif
  41. #if defined(SIZEOF_LONG_LONG)
  42. static_assert(sizeof(long long) == SIZEOF_LONG_LONG, "fixme 12");
  43. #endif
  44. #if defined(SIZEOF_OFF_T)
  45. #include <stdio.h>
  46. static_assert(sizeof(off_t) == SIZEOF_OFF_T, "fixme 13");
  47. #endif
  48. #if defined(SIZEOF_PID_T)
  49. #include <unistd.h>
  50. static_assert(sizeof(pid_t) == SIZEOF_PID_T, "fixme 14");
  51. #endif
  52. #if defined(SIZEOF_SHORT)
  53. static_assert(sizeof(short) == SIZEOF_SHORT, "fixme 15");
  54. #endif
  55. #if defined(SIZEOF_WCHAR_T)
  56. static_assert(sizeof(wchar_t) == SIZEOF_WCHAR_T, "fixme 16");
  57. #endif
  58. #if defined(SIZEOF__BOOL)
  59. //TODO
  60. #endif
  61. """
  62. if __name__ == '__main__':
  63. with open(sys.argv[2], 'w') as f:
  64. f.write('#include <' + sys.argv[1] + '>\n\n')
  65. f.write(data)