Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 07 Sep 2001 12:11:52 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Bill Fenner <fenner@research.att.com>
Cc:        arch@freebsd.org
Subject:   Re: Causing <netinet/in.h> to depend on <sys/socket.h>
Message-ID:  <3B991BF8.5BF2E5E2@mindspring.com>
References:  <200109071748.KAA21991@windsor.research.att.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Bill Fenner wrote:
> 
> Er, I think I take back my own objection.  IEEE Std 1003.1-200x says
> 
> SYNOPSIS
>               #include <netinet/in.h>
> ...
>               Inclusion of the <netinet/in.h> header may also make
>               visible all symbols from <inttypes.h> and <sys/socket.h>.

... and it MAY not.

You should just include both yourself, and be done with it.

By forcing inclusion of socket.h, you break the layering
abstraction.

If this is done with pointers, rather than instances or
member references, in the API code, just forward declare
the structure, and use it as an opaque type, e.g.:

	struct socket;

	struct foo {
		struct socket *mysock;
		...
	};

As long as it's a pointer, the compiler will not balk at it
being an incomplete type, unless you attempt to dereference
it.  Since that should only ever happen in code, and code
does not belong in header files, problem solved.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B991BF8.5BF2E5E2>