Re: #include optimization
Hi there,
[color=blue][color=green][color=darkred]
>>>>I am currently maintaining a legacy code with a very very large code
>>>>base. I am facing problems with C/C++ files having a lot of
>>>>un-necessary #includes. On an average every C/C++ file has around
>>>>150+ .h files included. I find 75% of the files unnecessary and
>>>>could be removed. Considering the fact that I have a huge code base,
>>>>I can't manually fix it.
>>>
>>>If it ain't broken, don't fix it.[/color]
>>
>>Unless fixing it will make future maintenance easier, which is
>>probably the case here.[/color]
>
> Why?[/color]
I cannot look into Keith's head but one possible reason is that
from looking at which file includes which header you get information
where to look when changing something.
Especially in huge codes with many man years of work in them and
too few man days of documentation work and me not being an expert,
this (e.g. by find . -type f -exec grep obscureheader.h \{} -print)
is -- after browsing around with tags -- one step I might
take to get a feeling for how this connects with that and whether some
people took "shortcuts" somewhere that need to be fixed.
If you basically have people including about fifty header files for
no reason in every translation unit they get into their hands so
that they do not have to know about where which functions, definitions
and so on come from, then this approach obviously is not feasible.
Just a guess.
Cheers
Michael
Hi there,
[color=blue][color=green][color=darkred]
>>>>I am currently maintaining a legacy code with a very very large code
>>>>base. I am facing problems with C/C++ files having a lot of
>>>>un-necessary #includes. On an average every C/C++ file has around
>>>>150+ .h files included. I find 75% of the files unnecessary and
>>>>could be removed. Considering the fact that I have a huge code base,
>>>>I can't manually fix it.
>>>
>>>If it ain't broken, don't fix it.[/color]
>>
>>Unless fixing it will make future maintenance easier, which is
>>probably the case here.[/color]
>
> Why?[/color]
I cannot look into Keith's head but one possible reason is that
from looking at which file includes which header you get information
where to look when changing something.
Especially in huge codes with many man years of work in them and
too few man days of documentation work and me not being an expert,
this (e.g. by find . -type f -exec grep obscureheader.h \{} -print)
is -- after browsing around with tags -- one step I might
take to get a feeling for how this connects with that and whether some
people took "shortcuts" somewhere that need to be fixed.
If you basically have people including about fifty header files for
no reason in every translation unit they get into their hands so
that they do not have to know about where which functions, definitions
and so on come from, then this approach obviously is not feasible.
Just a guess.
Cheers
Michael
Comment