[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Ways to check for symbols
From: |
Robert Lowe |
Subject: |
Ways to check for symbols |
Date: |
Thu, 29 Dec 2005 11:33:12 -0600 |
User-agent: |
Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) |
Hi!
After hunting for a bit, I came across several ways to check the
presence of a symbol in a header file. I was interested in
INADDR_NONE, so I tried the following methods:
1) AC_CHECK_DECL: I had to experiment a bit with AC_CHECK_DECL --
the vagueness in the existing documentation is outlined here:
http://lists.gnu.org/archive/html/bug-autoconf/2003-01/msg00006.html
I landed on:
AC_CHECK_DECL([INADDR_NONE], , , [#include <netinet/in.h>])
2) AC_CHECK_HEADER:
AC_CHECK_HEADER([netinet/in.h],
AC_DEFINE(HAVE_NETINET_IN_H, 1,
[Define to 1 if you have the <netinet/in.h> header file.])
AC_MSG_CHECKING([for INADDR_NONE in netinet/in.h])
AC_TRY_LINK([
#include <stdio.h>
#include <netinet/in.h>
], [ printf( "%xu", INADDR_NONE ); ],
[AC_MSG_RESULT(found) ],
[AC_MSG_RESULT(not found)
AC_DEFINE(NEED_INADDR_NONE, 1,
[Define to 1 if INADDR_NONE not present])])
)
Then it occurred to me that I might be trying to pound in a thumb tack
with a sledgehammer, and that:
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffffU
#endif
...would do just fine.
So, just what are the merits, and possible pitfalls of any of these
approaches??
<Disclaimer>Still an autotools newbie!</Disclaimer>
--
Robert
A mind once stretched by a new idea never regains its original
dimension. <Oliver Wendell Holmes Jr. (1841 - 1935)>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Ways to check for symbols,
Robert Lowe <=