On Tue, Dec 04, 2012 at 09:59:54AM +0100, Michal Privoznik wrote:
On 03.12.2012 17:45, Daniel P. Berrange wrote:
> Thus far we only have one rule about header files, #include <config.h>
> must be first in all .c files. I'm wondering if it is time to introduce
> some new rules
>
> - All system headers must be grouped to preceed all local headers
> - All system headers must be sorted within their group
> - All local headers must be sorted within their group
>
> This will require updating pretty much every single source and header
> file in the tree. Of course it will need a new syntax check rule to
> validate this too. Since fixing them is a serious amount of work,
> I was wondering about people's opinions on this ?
>
> The goal is just standardization to make code a little more readable.
>
> Daniel
>
I feel indifferent about the last two. Personally alphabetical sorting
would make it in fact harder if one is including twin header files, e.g.
for stat(2) you need to include:
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
That is really a bogus manpage description. These days, all system
header files are intended to be self-contained, so for 'stat' you
only need sys/stat.h. This is shown correctly in the POSIX specs
http://pubs.opengroup.org/onlinepubs/9699919799/functions/stat.html
Even if that were not the case, your example doesn't scale - for example,
what would you do if using another function required
#include <sys/stat.h>
#include <fcntl.h>
you can't satisfy grouping of both sets of headers now, so IMHO, alphabetical
is the only option left at that point, other than "random" which is what
we have now.
Regards,
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|