c_util.h 520 B

12345678910111213141516171819
  1. #ifndef C_UTIL_H_INCLUDED
  2. #define C_UTIL_H_INCLUDED
  3. /* C language stuff. Doesn't involve any libraries that aren't part of
  4. the compiler.
  5. */
  6. #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
  7. /* GNU_PRINTF_ATTR lets the GNU compiler check printf-type
  8. calls to be sure the arguments match the format string, thus preventing
  9. runtime segmentation faults and incorrect messages.
  10. */
  11. #ifdef __GNUC__
  12. #define GNU_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
  13. #else
  14. #define GNU_PRINTF_ATTR(a,b)
  15. #endif
  16. #endif