Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Easily add "#pragma once" to multiple ".h" and ".hpp" header files
Ruby
Branch: master

This branch is 8 commits ahead, 8 commits behind m-ryan:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib
.gitignore
CHANGELOG
LICENCE
README.rdoc
magic_pragma.gemspec

README.rdoc

Magic pragma

Magic Pragma is a little tool that allows you to quickly add the “#pragma once” that indicate header file should only be included once, which is a common task for C++ programmers, for an entire directory structure.

Manuel Ryan originally wrote the magic_encoding(github.com/m-ryan/magic_encoding) gem to get rid of “invalid multibyte char (US-ASCII)” error of ruby. I thought, hey! This little tool should also be useful to C++ programmers like me! So I forked it, changed it, used it on my C++ projects. Hope you don't mind Ryan :)

Installation

gem install magic_pragma

Usage

you can call the tool from the console with default parameters like so

magic_pragma

this will prepend every “.h” and “.hpp” file in the working directory (recursively) with the following line :

#pragma once

Notes :

  • existing #pragma once are replaced

  • the rest of the file remains unchanged

you can pass options to the tool to specify the desired pragma (other than 'once') and the path where you want the tool to run, for example :

magic_pragma auto_inline /path/to/cpp/project

Thanks goes to Manuel Ryan for the original work.

Something went wrong with that request. Please try again.