Skip to content

Conversation

crasbe
Copy link
Contributor

@crasbe crasbe commented Apr 23, 2025

Contribution description

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.

This came up in #21429 (here: #21429 (comment) ) and previous Pull Requests while working on #21335.

Testing procedure

Add a leading whitespace to the #pragma once of a header file of your liking (in this case I chose core/include/msg.h) and run the static test.

Current master (not very helpful):

cbuec@W11nMate:~/RIOTstuff/riot-suit/RIOT$ ./dist/tools/headerguards/check.sh
core/include/msg.h: no / broken header guard

With this PR (prints a suggestion to fix the issue):

cbuec@W11nMate:~/RIOTstuff/riot-suit/RIOT$ ./dist/tools/headerguards/check.sh
--- core/include/msg.h
+++ core/include/msg.h
@@ -6,7 +6,7 @@
  * directory for more details.
  */

- #pragma once
+#pragma once

 /**
  * @defgroup    core_msg  Messaging / IPC

Issues/PRs references

Useful for #21335.

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.
@crasbe crasbe added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Apr 23, 2025
@github-actions github-actions bot added the Area: tools Area: Supplementary tools label Apr 23, 2025
@riot-ci
Copy link

riot-ci commented Apr 23, 2025

Murdock results

✔️ PASSED

ab1356e dist/tools: add a leading whitespace check for #pragma once

Success Failures Total Runtime
1 0 1 01m:17s

Artifacts

@maribu maribu enabled auto-merge April 24, 2025 07:27
@maribu maribu added this pull request to the merge queue Apr 24, 2025
@maribu maribu removed this pull request from the merge queue due to the queue being cleared Apr 24, 2025
@maribu maribu added this pull request to the merge queue Apr 24, 2025
Merged via the queue into RIOT-OS:master with commit ec94a3c Apr 24, 2025
28 checks passed
@crasbe crasbe deleted the pr/whitespace_pragma branch April 24, 2025 08:56
@Teufelchen1 Teufelchen1 added this to the Release 2025.07 milestone Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants