[systemd-devel] Removing unnecessary includes

Thomas H.P. Andersen phomes at gmail.com
Sat Feb 7 06:37:06 PST 2015


On Sat, Feb 7, 2015 at 2:05 PM, Daniele Nicolodi <daniele at grinta.net> wrote:
> On 07/02/15 10:29, Thomas H.P. Andersen wrote:
>> I am looking at ways to automatically trim the unnecessary includes.
>> One way to do it is a script[1] which simply tests if the compile
>> still works after removing each include one at a time. It does this in
>> reverse order for all includes in the .c files. Using -Werror we catch
>> any new warnings too.
>
> Hello Thomas,
>
> this approach is not correct: in this way each source file would not be
> required to include the headers included by other files included before.
> For example, if header file "a.h" includes "shared.h" and implementation
> file requires the definitions of "a.h" and "shared.h", only the first
> dependency would be detected by this method.
>
> However, it is good practice to include all the required header files,
> whether those are already included by others or not.

Oh, I did not mean to use the output of deheader directly. Only as a
way to find potential targets for removal. Each removal should be
reviewed manually of course.

> Cheers,
> Daniele
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list