Date: Wed, 28 Nov 2012 07:45:11 +0100 From: Martin Sustrik <sustrik@250bpm.com> To: Bruce Evans <brde@optusnet.com.au> Cc: freebsd-bugs@FreeBSD.org Subject: Re: Possible non-conformance to POSIX Message-ID: <50B5B2F7.9050801@250bpm.com> In-Reply-To: <50B59F3D.5030102@250bpm.com> References: <50B53938.2010601@250bpm.com> <20121128092318.U1509@besplex.bde.org> <50B59F3D.5030102@250bpm.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 28/11/12 06:21, Martin Sustrik wrote:
> On 27/11/12 23:39, Bruce Evans wrote:
>
>>> #include <netinet/in.h>
>>> INADDR_ANY;
>>>
>>> The above results in 'u_int32_t undefined' error, which it shouldn't
>>> according to POSIX.
>>
>> <netinet/in.h> is careful to only declare uint32_t, but then it is
>> broken and uses u_int32_t for INADDR_ANY and INADDR_BROADCAST.
>> u_int32_t is also misused extensively in the definitions of INADDR_*
>> and IN_* under __BSD_VISIBLE. INADDR_ANY is broken even if __BSD_VISIBLE
>> is nonzero (the default), because the u_int32_t pollution is not
>> automatically supplied with __BSD_VISIBLE. It takes including
>> <sys/types.h> (with __BSD_VISIBLE) to get it.
>
> Yes. I figured out that including <sys/types.h> solves the problem. I
> was just pointing out the bug.
>
> If there's interest I can send a patch for INADDR_ANY and INADDR_BROADCAST.
I should also add that the problem is important because of feature
checking in different build tools. The tool usually checks the existence
of a symbol by trying to compile something like this:
#include <netinet/in.h>
INADDR_ANY;
int main () {return 0;}
If the compilation fails, it assumes the symbol is not defined. Which in
not true in this context.
Btw, I've found another similar problem. Trying to compile the following:
#include <getifaddrs.h>
int main () {return 0;}
results in:
/usr/include/ifaddrs.h:34: error: expected specifier-qualifier-list
before 'u_int'
Which, of course, means that the build tool (CMake in this case) reports
that getifaddrs.h file is not available on FreeBSD platform.
Martin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50B5B2F7.9050801>
