[bind10-dev] networking includes

Francis Dupont fdupont at isc.org
Sun Jul 1 16:16:23 UTC 2012


There are a lot of occurrences of:

#include <unistd.h>             // for some IPC/network system calls
#include <netinet/in.h>
#include <sys/socket.h>

which are clearly very OS dependent (for WIN32 it is <ws2tcpip.h>).
Another issue is where to put them: in some cases they must be early
because they interferes in strange ways with for instance the ASIO
includes, including indirectly (i.e., by an include of a bind 10 .h).

There is a drastic but efficient way to solve this: add OS dependent
includes in the config.h (*) and of course include config.h (first!)
in all files showing this kind of need. The clear drawback is to
include too many but it is not as calling Ackermann's function in
templates a la boost...

Another question is whether to put the include for config.h in header
(.h) files or code (.cc) files. IMHO it is clearly the second: header
files should include only "internal" headers.

Regards

Francis Dupont <fdupont at isc.org>

PS: this is strongly related to my next message about the socket
descriptor type.
PPS (*): for the auto* stuff the @TOP@/@BOTTOM@ device in acconfig.h
controls the addition of specific defines/includes/etc in the
config.h.


More information about the bind10-dev mailing list