Skip to content

tracking: replacing header guards with #pragma once #21335

@N11cc00

Description

@N11cc00

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.

Previously this issue tracked the effort to bring the header guards into the correct order to work with clang-format. Recently it was decided that from now on, RIOT would use the #pragma once macro instead. This means that some of the previous pull request are outdated and every part of the RIOT repo needs to be updated.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: docArea: DocumentationType: cleanupThe issue proposes a clean-up / The PR cleans-up parts of the codebase / documentationType: trackingThe issue tracks and organizes the sub-tasks of a larger effort

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions