All Projects → cgmb → Guardonce

cgmb / Guardonce

Licence: mit
Utilities for converting from C/C++ include guards to #pragma once and back again.

Programming Languages

python
139335 projects - #7 most used programming language
c
50402 projects - #5 most used programming language
cpp
1120 projects

Labels

Projects that are alternatives of or similar to Guardonce

Musicdownloader
Material design YouTube mp3/mp4 downloader
Stars: ✭ 70 (-32.04%)
Mutual labels:  converter
Kefirbb
A flexible Java text processor. BB, BBCode, BB-code, HTML, Textile, Markdown, parser, translator, converter.
Stars: ✭ 83 (-19.42%)
Mutual labels:  converter
Av Converter
[av-converter.com] Audio and Video Converter, and YouTube downloader. Convert to MP3, MP4, AAC, FLAC, AC3, WAV, etc.
Stars: ✭ 97 (-5.83%)
Mutual labels:  converter
Seonbi
SmartyPants for Korean language
Stars: ✭ 76 (-26.21%)
Mutual labels:  converter
Jalali.py
Persian and Gregorian Date Converter for Python 2 and Python 3
Stars: ✭ 82 (-20.39%)
Mutual labels:  converter
Html To Markdown
Convert HTML to Markdown with PHP
Stars: ✭ 1,293 (+1155.34%)
Mutual labels:  converter
Instatrack
Convert Instagram user ID to username & vice versa
Stars: ✭ 70 (-32.04%)
Mutual labels:  converter
Ffmpeg Gif Script For Bash
Turn your videos into palette-mapped gifs with this easy script
Stars: ✭ 100 (-2.91%)
Mutual labels:  converter
Fb2converter
Unified converter of FB2 files into epub2, kepub, mobi and azw3 formats.
Stars: ✭ 83 (-19.42%)
Mutual labels:  converter
Epoch
A simple but powerful Epoch converter
Stars: ✭ 94 (-8.74%)
Mutual labels:  converter
Currencyconverter
Utilities for doing currency conversion with the Money library
Stars: ✭ 78 (-24.27%)
Mutual labels:  converter
Perun
A command-line validation tool for AWS Cloud Formation that allows to conquer the cloud faster!
Stars: ✭ 82 (-20.39%)
Mutual labels:  converter
Alfred Calculate Anything
Alfred Workflow to calculate anything with natural language
Stars: ✭ 92 (-10.68%)
Mutual labels:  converter
Youtube Channel Name Converter
A Youtube Channel Name to ID Converter
Stars: ✭ 75 (-27.18%)
Mutual labels:  converter
Kramdown Asciidoc
A kramdown extension for converting Markdown documents to AsciiDoc.
Stars: ✭ 97 (-5.83%)
Mutual labels:  converter
Gluon2pytorch
Gluon to PyTorch deep neural network model converter
Stars: ✭ 70 (-32.04%)
Mutual labels:  converter
Png To Ico
convert png to ico format
Stars: ✭ 88 (-14.56%)
Mutual labels:  converter
Pkhex.mobile
Pokémon save editor on the go!
Stars: ✭ 101 (-1.94%)
Mutual labels:  converter
Lambda Converters
Strongly-typed lambda expressions as value converters, data template selectors, and validation rules
Stars: ✭ 99 (-3.88%)
Mutual labels:  converter
Wx Voice
Convert audio files between Tencent apps (Weixin / Wechat, QQ) and Silk codec with other general formats such as MP3 and M4A
Stars: ✭ 93 (-9.71%)
Mutual labels:  converter

guardonce

Utilities for converting from C/C++ include guards to #pragma once and back again.

Why Convert?

Include guards suck. They're tiring to type and tedious to update. Worse, the task of updating boilerplate leaves room for copy/paste errors, or other mistakes. #pragma once is simpler and less error prone. That's why you should convert to #pragma once.

Alas, though #pragma once is available on all the most commonly used compilers, it's not available on every compiler. Perhaps one day you'll add support for a platform with a barebones compiler with no support for #pragma once and you'll have to convert back. That's ok. It's easy!

What exactly is guardonce?

There are three main tools provided by guardonce:

  1. checkguard helps find any broken include guards you may already have in your project. These should be addressed before converting.

  2. guard2once converts files with include guards into files with #pragma once directives. This ensures your entire project is consistently using #pragma once.

  3. once2guard converts files with #pragma once directives back into files with include guards. This ensures your entire project is consistently using include guards.

How to use:

First, check your project for broken headers. To recursively search your project directories for the names of all files that lack proper include guards, use the following command, substituting your project's directory for the quoted string:

checkguard -r "source_directory"

By default, checkguard is very forgiving. It accepts either #pragma once or anything that looks like an include guard. If you know that all your guards should match some format, you can be more strict by using -p to specify a pattern to check against.

If certain files are not supposed to have include guards, feel free to leave them be. Files without include guards are ignored by this next step.

Now, all that remains is converting the headers to use #pragma once:

guard2once -r "source_directory"

You're done! Double check that the result matches your expectations and start using #pragma once in your new code. Know that if you ever need to switch back, it's as simple as:

once2guard -r "source_directory"

If the default guard style doesn't appeal to you, there are a few options to customize it. Maybe take a look through once2guard --help or check out a walkthrough for some examples.

How to Install:

Whether you use Python 2 or Python 3, these tools can be installed with pip. Run python -m pip install guardonce and you're off to the races.

If you'd rather not use pip, it is possible to instead just run from the repository. However, you'll need to use slightly different commands. Add the repository to your PYTHONPATH and invoke the tools as python modules, as illustrated below.

Linux / OSX

git clone https://github.com/cgmb/guardonce.git
export PYTHONPATH="$(pwd)/guardonce"
python -m guardonce.checkguard -r ~/myproject

Windows

git clone https://github.com/cgmb/guardonce.git
set "PYTHONPATH=%CD%\guardonce"
python -m guardonce.checkguard -r ~/myproject

Note that on Windows you might need to invoke guardonce via python -m even if you install with pip.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].