8000 tracking: fixing order of doxygen tags and header guards · Issue #21335 · RIOT-OS/RIOT · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

tracking: fixing order of doxygen tags and header guards #21335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 8 tasks
KSKNico opened this issue Mar 28, 2025 · 11 comments
Open
1 of 8 tasks

tracking: fixing order of doxygen tags and header guards #21335

KSKNico opened this issue Mar 28, 2025 · 11 comments
Labels
Area: doc Area: Documentation Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Type: tracking The issue tracks and organizes the sub-tasks of a larger effort

Comments

@KSKNico
Copy link
Contributor
KSKNico commented Mar 28, 2025

Description

Clang-format requires the header guard #ifndef #define HEADER_GUARD_H to be outside of the doxygen documentation, that means outside the @{ ... @} block. If this is not done, then clang-format will indent all preprocessor directives after the #ifndef.
The problem is that the majority of RIOT's header files don't adhere to this order. They either have the header guard inside the doxygen block or the header guard starts correctly outside the doxygen block but the #endif directive is still inside the doxygen documentation.
To fix this inconsistency, I have written a python script that recursively scans all header files in a directory and rearranges the parts, so that the correct order is established.

Fixed directories

Testing procedure

Use my python script and change the path variable 'RIOT_PATH' in the script to whatever directory you want to recursively fix the header files.
Warning: the script isn't fool-proof but fixes 95% of all header files that have this issue. There are individual issues with the formatting that require manual intervention.

The script can be found here

Application

This is based on the fix in #20905 addressed by @mguetschow but with the added benefit of keeping the blocks balanced.

@mguetschow
Copy link
Contributor

The order should also be fixed in https://github.com/aabadie/riot-generator

@crasbe crasbe added Area: doc Area: Documentation Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Type: tracking The issue tracks and organizes the sub-tasks of a larger effort labels Mar 28, 2025
@crasbe
Copy link
Contributor
crasbe commented Mar 31, 2025

I wonder if your Python script could be adapted and added to the static tests, so that for future contributions, the include guards are checked as well before merging 🤔

@KSKNico
Copy link
Contributor Author
KSKNico commented Mar 31, 2025

I wonder if your Python script could be adapted and added to the static tests, so that for future contributions, the include guards are checked as well before merging 🤔

This seem like a very reasonable addition. I have yet to look into CI stuff as I have never worked with it.

@crasbe
Copy link
Contributor
crasbe commented Mar 31, 2025

There is some documentation in the dist/tools/ci folder https://github.com/RIOT-OS/RIOT/tree/master/dist/tools/ci and you can look at how the check-scripts are called by dist/tools/ci/static_tests.sh and how they operate.

You don't necessarily have to look into CI for that, the script is executed when you call make static-test and that's exactly what the CI system does as well.

Enoch247 added a commit to Enoch247/RIOT that referenced this issue Apr 2, 2025
This patch updates the example given to conform to the recomended
placement of include guards.

See issue RIOT-OS#21335
Enoch247 added a commit to Enoch247/RIOT that referenced this issue Apr 3, 2025
This patch updates the example given to conform to the recomended
placement of include guards.

See issue RIOT-OS#21335
@benpicco
Copy link
Contributor
benpicco commented Apr 3, 2025

Should we just move to #pragma once instead?

@carl-tud
Copy link
Contributor
carl-tud commented Apr 3, 2025

@benpicco Yes!!

@Enoch247
Copy link
Contributor
Enoch247 commented Apr 3, 2025

That would be fine by me.

@mguetschow
Copy link
Contributor

We had that discussion at VMA 2024.11 and had general consensus on switching to #pragma once, while having some reservation about the necessary migration work to keep in-tree consistency. Since we are now anyways touching a lot of header files, there was consensus at today's maintainer weekly that we can just as well use that work to switch over to #pragma once.

@Enoch247
Copy link
Contributor
Enoch247 commented Apr 6, 2025

Awesome! I have updated #21344 to make use of the #pragma once.

@crasbe
< 8000 span data-view-component="true"> Copy link
Contributor
crasbe commented Apr 6, 2025

For #pragma once, the dist/tools/headerguards/headerguards.py script has to be modified, otherwise the static tests fail:

Image

@JerelJr
Copy link
Contributor
JerelJr commented Apr 11, 2025

Hello, I am new to the RIOT community and would like to help fix the headers. I can start in the core folder if no one is working on that already. Also, I made a modified version of @KSKNico's script to replace the header guard entirely with #pragma once which may be helpful.

Lukas-Luger pushed a commit to Lukas-Luger/RIOT that referenced this issue Apr 14, 2025
This patch updates the example given to conform to the recomended
placement of include guards.

See issue RIOT-OS#21335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: doc Area: Documentation Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Type: tracking The issue tracks and organizes the sub-tasks of a larger effort
Projects
None yet
Development

No branches or pull requests

7 participants
0