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 :)
gem install magic_pragma
you can call the tool from the console with default parameters like so
this will prepend every “.h” and “.hpp” file in the working directory (recursively) with the following line :
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.