Converts C/C++ preprocessor include guards from the `#ifndef XY_H`, `#define XY_H` to the `#pragma once` paradigm.
Project description
include-guard-convert
Converts C/C++ preprocessor include guards from the #ifndef XY_H, #define XY_H to the #pragma once paradigm.
Header files have the problem that they should be included once per compile unit; thus, they usually deploy a scheme that looks like this
/*
* some funky comment, doxygen, copyright info
*/
#ifndef MY_HEADERFILE_H
#define MY_HEADERFILE_H
class declare_and_define_whatever_you_want
{
...
};
#endif /* maybe a comment that this belongs to MY_HEADERFILE_H */
Since this lead to a few bugs (namely, sometimes there are #define naming conflicts, or copy&paste errors), I've wrote a script to make the same file look like this:
/*
* some funky comment, doxygen, copyright info
*/
#pragma once
class declare_and_define_whatever_you_want
{
...
};
Dependencies
- C preprocessor (only tested with the GCC cpp)
- Python 3 (tested with 3.8.2)
Caveats
- The include guards should be the surround the whole semantic content of the file. That means that
#ifndefmust be on the first non-comment, non-whitespace, non-empty line of your source code and that it must end with the matching#ifndefline, which may only be followed by empty or whitespace-only lines. - The
#defineconstants must beUPPERCASE_UNDERSCORE_0_TO_9_ONLYstyle.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file include_guard_convert-1.0.0.tar.gz.
File metadata
- Download URL: include_guard_convert-1.0.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa5838cc89474c5bbdc4bb3b5a4c36b4d5dfa413a46a3f6f454a8b9345a8fa1f
|
|
| MD5 |
f9464cce501c7d70b592d94bac30bf8e
|
|
| BLAKE2b-256 |
af31504c38e3e155bad85b3760896f5d506f9316766bbe919a62d4ba80f24577
|
File details
Details for the file include_guard_convert-1.0.0-py3-none-any.whl.
File metadata
- Download URL: include_guard_convert-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e78d4b930c1fde009b0fb051f3569de0896075db7d24b947161ed717b9848e6f
|
|
| MD5 |
ba5902db3d5c0d7917d2e36f05ade552
|
|
| BLAKE2b-256 |
376d5c62d975d7e901f8cfdd901415518c471c0b0de44c5d6fc5ad135f9f69e9
|