Our current scheme is to use #include "" for internal headers, and #include <> for external ones.
Unfortunately this is not based on compiler support: from C point of view, the "" form merely looks up headers in the current directory and then falls back on <> directories. Thus, for example, a system header trace.h - should it be present - will conflict with our local trace.h As another example of problems, a header by the same name in the source directory will always be picked up first - before any headers in the include directory. Let's change the scheme: make sure all headers that are not in the source directory are included through a path starting with qemu/ , thus: #include <> headers in the same directory as source are included with #include "" as per standard. This (untested) patch is just to start the discussion and does not change all of the codebase. If there's agreement, this will be run on all code to converting code to this scheme. Signed-off-by: Michael S. Tsirkin <m...@redhat.com> --- scripts/changeheaders.pl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 scripts/changeheaders.pl diff --git a/scripts/changeheaders.pl b/scripts/changeheaders.pl new file mode 100755 index 0000000..22bd5b8 --- /dev/null +++ b/scripts/changeheaders.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl -pi + +if (m@^\s*#include\s+"([^"+]"@o) { + next; +} + +my $hdr = $1; +my $file = $ARGV; +$file =~ s@/[^/]+$@@g; +$file .= $hdr; + +if (-e $file) { + next; +} + +if (m@^\s*#include\s+"qemu/@o) { + s@^(\s*#include\s+)"qemu/([^"]+)"(.*)$@$1<qemu/common/$2>$3@o) { +} else { + s@^(\s*#include\s+)"([^"]+)"(.*)$@$1<qemu/$2>$3@o) { +} -- MST _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel