[asterisk-dev] [asterisk-commits] rizzo: trunk r89379 - /trunk/include/asterisk/network.h

Simon Perreault simon.perreault at viagenie.ca
Sun Nov 18 12:57:29 CST 2007

On Saturday 17 November 2007 09:34:38 Luigi Rizzo wrote:
> in my view network.h is just to hide system differences
> (and provide trivial functions such as the one above),
> while netwock provides additional services
> for sockets (container, tls, etc.)

Yes, so why did you add inaddrcmp() to network.h? It doesn't exist on any 
platform, it's specific to Asterisk. So it goes into netsock.h, not 

> you keep saying that, and i don't understand why.

Sorry, I kept repeating because I thought my voice did not carry to you.

> The reason for aggregating is
> avoid repreating the #ifdef THIS #ifdef THAT all over the place.

I feel that's not a good enough reason. The better solution is to put the 
#ifdef magic in


, prepend asterisk/compat to the include path, and in the .c's use

#include <socket.h>
#include <stdint.h>

> In terms of compile times, i already posted them and as you see
> there is no measurable difference between the two versions.

The real problem is not with compile times. It's with good software 
engineering practices. By aggregating headers needlessly (there's no need to 
aggregate if you use the solution proposed above), you create a place where 
other people will add headers that are not supposed to be there. You know 
that the purpose of network.h is for system compat stuff, but other people in 
the future will now know this and quickly will begin adding macros, short 
inlines (you even did it with inaddrcmp()), and system headers vaguely 
related to network stuff. network.h will grow, and eventually two problem 
will appear:

1. It would be hard to tell which headers a .c that would include that big 
network.h really needs. As Russell wisely said, "there is some value in 
knowing which special headers are needed in a file".

2. Compile times. 'nuff said.

You don't *need* to aggregate. So don't.

Anyway, don't listen to me, I'm just coaching from the stands. ;)

More information about the asterisk-dev mailing list