Skip to content

Commit 082a37b

Browse files
committed
dist/tools/headerguards: ignore if #include_next is used
We can't use the same header guard if we include two files with the same name.
1 parent 6a08bff commit 082a37b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

dist/tools/headerguards/headerguards.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def fix_headerguard(filename):
4343
tmp.seek(0)
4444

4545
guard_found = 0
46+
include_next_found = 0
4647
guard_name = ""
4748
ifstack = 0
4849
for line in inlines:
@@ -66,14 +67,17 @@ def fix_headerguard(filename):
6667
else:
6768
guard_found += 1
6869
line = "#endif /* %s */\n" % supposed
70+
elif line.startswith("#include_next"):
71+
include_next_found = 1
6972

7073
tmp.write(line)
7174

7275
tmp.seek(0)
7376
if guard_found == 3:
74-
for line in difflib.unified_diff(inlines, tmp.readlines(),
75-
"%s" % filename, "%s" % filename):
76-
sys.stdout.write(line)
77+
if include_next_found == 0:
78+
for line in difflib.unified_diff(inlines, tmp.readlines(),
79+
"%s" % filename, "%s" % filename):
80+
sys.stdout.write(line)
7781
else:
7882
print("%s: no / broken header guard" % filename, file=sys.stderr)
7983
return False

0 commit comments

Comments
 (0)