Skip to content

Commit ab1356e

Browse files
committed
dist/tools: add a leading whitespace check for #pragma once
When adding the #pragma once after a comment block, many editors will remain at the previous indentation level, adding a leading whitespace to the #pragma once. This is invalid, but causes the headerguards check to fail. Since it is a common issue, it warrants a separate check with a proposed solution, just like for other headerguard issues that are checked.
1 parent d9938cc commit ab1356e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

dist/tools/headerguards/headerguards.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ def fix_headerguard(filename):
5050
for line in inlines:
5151
if line.startswith("#pragma once"):
5252
pragma_once_found += 1
53+
elif line.lstrip().startswith("#pragma once"):
54+
# check for lines that have leading whitespaces and add a correction
55+
pragma_once_found += 1
56+
line = "#pragma once\n"
5357
if guard_found == 0 and pragma_once_found == 0:
5458
if line.startswith("#ifndef"):
5559
guard_found += 1

0 commit comments

Comments
 (0)