I think there is a difference between requiring an extra header to use
the socket function and requiring an extra header to make your program
compile.  The former makes sense to me because you might want to use
some other function in the header that doesn't require sys/types.h
and not incur the extra overhead of including it.  However, if
netinet/in.h can't even compile without sys/types.h, then I don't see
any reason to leave the include out.

In any case, I guess it is okay to include it based on this note in
the Linux man page for socket(2):
       POSIX.1-2001 does not require the inclusion of <sys/types.h>, and  this
       header  file  is not required on Linux.  However, some historical (BSD)
       implementations required this header file,  and  portable  applications
       are probably wise to include it.

--David

bill fumerola wrote:
> On Tue, Oct 21, 2008 at 03:01:54AM -0700, David Reiss wrote:
>> So, I think I'd rather see this fixed in the OpenBSD packaging, unless
>> someone can make a case to me that this is not a ridiculous bug.
> 
> you'll have better luck changing the direction the earth rotates than
> you will convincing OpenBSD that anything they do is wrong.
> 
> their man pages document the header requirement.
> 
> IP(4)     OpenBSD Programmer's Manual IP(4)
> 
> NAME
>      ip - Internet Protocol
> 
> SYNOPSIS
>      #include <sys/socket.h>
>      #include <netinet/in.h>
> 
>      int
>      socket(AF_INET, SOCK_RAW, proto);
> 
> 
> 
> 
> -- bill
> 
> 
> 

Reply via email to