Skip to content

Instantly share code, notes, and snippets.

@wereHamster
Created August 29, 2012 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wereHamster/3516935 to your computer and use it in GitHub Desktop.
Save wereHamster/3516935 to your computer and use it in GitHub Desktop.
#/usr/bin/bash
# Add ifndef/define/endif to headers which use pragma once. I used
# it to edit some C++ project which wouldn't compile because the
# compiler didn't understand pragma once. SunCC, I'm looking at you!
~/bin/ack -l 'pragma once' | while read file; do
f="${file//\//_}"
f="${f//./_}"
f="$(echo "$f" | tr '[:lower:]' '[:upper:]')"
gsed -i "/#pragma once/ {
a#ifndef $f
a#define $f
}; \$a#endif /* $f */" $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment