cf: Resolve implicit function definition for memset
[openafs.git] / src / cf / have-struct-field.m4
1 dnl Borrowed from Heimdal, but renamed as I don't think we
2 dnl should be shipping AC_ macros.
3
4 AC_DEFUN([OPENAFS_HAVE_STRUCT_FIELD], [
5 define(cache_val, translit(ac_cv_type_$1_$2, [A-Z ], [a-z_]))
6 AC_CACHE_CHECK([for $2 in $1], cache_val,[
7 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
8         $3
9         #include <string.h>]],
10         [[$1 x; memset(&x, 0, sizeof(x)); x.$2]])],
11         [cache_val=yes],
12         [cache_val=no])
13 ])
14 if test "$cache_val" = yes; then
15         define(foo, translit(HAVE_$1_$2, [a-z ], [A-Z_]))
16         AC_DEFINE(foo, 1, [Define if $1 has field $2.])
17         undefine([foo])
18 fi
19 undefine([cache_val])
20 ])
21