Home | History | Annotate | Line # | Download | only in cf
have-struct-field.m4 revision 1.1.1.2
      1  1.1.1.2  elric dnl Id
      2      1.1  elric dnl
      3      1.1  elric dnl check for fields in a structure
      4      1.1  elric dnl
      5      1.1  elric dnl AC_HAVE_STRUCT_FIELD(struct, field, headers)
      6      1.1  elric 
      7      1.1  elric AC_DEFUN([AC_HAVE_STRUCT_FIELD], [
      8      1.1  elric define(cache_val, translit(ac_cv_type_$1_$2, [A-Z ], [a-z_]))
      9      1.1  elric AC_CACHE_CHECK([for $2 in $1], cache_val,[
     10      1.1  elric AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$3]],
     11      1.1  elric 	[[$1 x; memset(&x, 0, sizeof(x)); x.$2]])],
     12      1.1  elric 	[cache_val=yes],
     13      1.1  elric 	[cache_val=no])
     14      1.1  elric ])
     15      1.1  elric if test "$cache_val" = yes; then
     16      1.1  elric 	define(foo, translit(HAVE_$1_$2, [a-z ], [A-Z_]))
     17      1.1  elric 	AC_DEFINE(foo, 1, [Define if $1 has field $2.])
     18      1.1  elric 	undefine([foo])
     19      1.1  elric fi
     20      1.1  elric undefine([cache_val])
     21      1.1  elric ])
     22