[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AC_CHECK_MEMBER() fails if member is not castable to boolean
From: |
H. Peter Anvin |
Subject: |
AC_CHECK_MEMBER() fails if member is not castable to boolean |
Date: |
Sat, 05 Jan 2002 14:42:00 -0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.6) Gecko/20011120 |
From one of my own programs, trying to look for in_pktinfo.ipi_addr,
which is a struct in_addr:
----------------------------------
configure:8582: checking for struct in_pktinfo.ipi_addr
configure:8615: gcc -c -g -O2 -D_XPG4_2 -D_XOPEN_SOURCE -D__EXTENSIONS__
-D_BSD_SOURCE -D_ISO9X_SOURCE -D_OSF_SOU
RCE -D_XOPEN_SOURCE_EXTENDED -W -Wall -Wpointer-arith
-Wbad-function-cast -Wstrict-prototypes -Wmissing-prototype
s -Wmissing-declarations -Wnested-externs -Winline -Wwrite-strings
-Wundef -Wshadow -Wsign-compare -pipe conftes
t.c >&5
configure:8605: warning: function declaration isn't a prototype
configure: In function `main':
configure:8607: invalid operands to binary !=
configure:8618: $? = 1
configure: failed program was:
#line 8588 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <sys/uio.h>
#ifdef F77_DUMMY_MAIN
# ifdef __cplusplus
extern "C"
# endif
int F77_DUMMY_MAIN() { return 1; }
#endif
int
main ()
{
static struct in_pktinfo ac_aggr;
if (ac_aggr.ipi_addr)
return 0;
;
return 0;
}
configure:8634: result: no
----------------------------------------
The problem here, of course, is that ac_aggr.ipi_addr isn't castable to
int (for old C compilers) or _Bool (for newer C compilers), so
"if (ac_aggr.ipi_addr)" is bogus.
A better variation might be the following:
if ( &(ac_aggr.ipi_addr) != (void *)0 )
return 0;
This, however, will fail if ipi_addr is a bitfield type. It might be
useful to have a different macro for bitfield types, I don't know.
-hpa
- AC_CHECK_MEMBER() fails if member is not castable to boolean,
H. Peter Anvin <=