Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 07 May 2002 09:37:03 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        aaron <aaron@lo-res.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: /usr/include/netinet/in.h
Message-ID:  <3CD802AF.45825A2C@mindspring.com>
References:  <200205071814.46995.aaron@lo-res.org>

next in thread | previous in thread | raw e-mail | index | archive | help
aaron wrote:
> I am just trying to write a simple IPv6 socket app.
> after #including <netinet/in.h> I noticed that I have to include <sys/types.h>
> BEFORE <netinet/in.h> which struck me as rather strange...
> 
> Should not .h files include the depending .h files themselves so that all
> dependencies of type / struct / #define definitions are met automatically?


Such an arrangement is called "promiscuous includes".

The problems with doing this are many, but the main ones are:

o	Including a file to get something expected into the namespace
	drags unexpected things into the namespace (perhaps a lot of
	them).

o	Compilation times go up geometrically

o	The programmer is shielded from explicit knowledge of the
	included files; this is bad, since it's the programmer's
	job to know these things

o	The resulting code is not portable to all platforms

o	Header files that do this are not technically standards
	compliant, since the standards dictate which header files
	are needed to access which functions in the API.

-- Terry

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3CD802AF.45825A2C>