[clug] C programming question: What goes in 'include' files??

Ben Nizette bn at niasdigital.com
Fri Aug 26 00:49:27 MDT 2011


On 26/08/2011, at 2:16 PM, steve jenkin wrote:

> Thanks for the answers.
> 
> I hadn't thought about 'static'.
> Still not sure it's good practice to include identical code in two
> places, but each one is small, so what the heck...

The compiler does this automagically for various -O values and 'inline' keywords - like a lot in programming it's a speed/size tradeoff.

> 
> The codebase creates a 'kernel' based on the OS+CPU-arch
> and another sub-system ('os') based solely on the CPU-architecture.
> 
> It includes the same code in both sub-systems in this case.

This is probably the kind of concept Tridge would be well across, Samba's one of those same kinds of code bases where a number of interrelated libraries are built on other libraries then pulled together again later on, if you don't manage it carefully things can go quite badly for you.  ISTR a PSIG meeting several months back were Tridge was saying that their move to the waf build system allowed them to be smarter about redundant code removal in these cases and they could reduce their binary sizes by, I donno, I forget the figure, but it was crazy.


	--Ben.
> 
> steve jenkin wrote on 24/08/11 12:46 AM:
>> The C code I've been looking at recently (hence desire for PPC & 386
>> builds) has what appears to me some quirky traits:
>> 
>> - include files contain functions, not just their prototypes
>>   [as well as the usual constant #defs]
> 
> 
> 
> -- 
> Steve Jenkin, Info Tech, Systems and Design Specialist.
> 0412 786 915 (+61 412 786 915)
> PO Box 48, Kippax ACT 2615, AUSTRALIA
> 
> sjenkin at canb.auug.org.au http://members.tip.net.au/~sjenkin
> -- 
> linux mailing list
> linux at lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux



More information about the linux mailing list