ax_emptyarray.m4 837 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. dnl @synopsis AX_EMPTY_ARRAY
  2. dnl
  3. dnl Define EMPTY_ARRAY_SIZE to be either "0"
  4. dnl or "" depending on which syntax the compiler
  5. dnl prefers for empty arrays in structs.
  6. dnl
  7. dnl @version
  8. dnl @author James Yonan <jim@yonan.net>
  9. AC_DEFUN([AX_EMPTY_ARRAY], [
  10. AS_VAR_PUSHDEF([VAR],[ax_cv_c_empty_array])dnl
  11. AC_CACHE_CHECK(
  12. [for C compiler empty array size],
  13. [VAR],
  14. [AC_COMPILE_IFELSE(
  15. [AC_LANG_PROGRAM(
  16. ,
  17. [[
  18. struct { int foo; int bar[0]; } mystruct;
  19. ]]
  20. )],
  21. [VAR=0],
  22. [AC_COMPILE_IFELSE(
  23. [AC_LANG_PROGRAM(
  24. ,
  25. [[
  26. struct { int foo; int bar[]; } mystruct;
  27. ]]
  28. )],
  29. [VAR=],
  30. [AC_MSG_ERROR([C compiler is unable to creaty empty arrays])]
  31. )]
  32. )]
  33. )dnl
  34. AC_DEFINE_UNQUOTED(
  35. [EMPTY_ARRAY_SIZE],
  36. [$VAR],
  37. [Dimension to use for empty array declaration]
  38. )dnl
  39. AS_VAR_POPDEF([VAR])dnl
  40. ])