Skip to content

Instantly share code, notes, and snippets.

@lukexi
Last active December 20, 2015 20:39
Show Gist options
  • Save lukexi/e11668ced04524564a8b to your computer and use it in GitHub Desktop.
Save lukexi/e11668ced04524564a8b to your computer and use it in GitHub Desktop.
Clang wrapper script to pass "-x assembler-with-cpp" to clang in preprocessor mode
import System.Environment
import System.Process
flags =
[ "-Wno-invalid-pp-token"
, "-Wno-unicode"
, "-Wno-trigraphs"
]
-- See if we're in preprocessor mode
check args@("-E":"-undef":"-traditional":_) = replace args
check other = other
-- make sure we use assembler-with-cpp
replace ("-x":"c":xs) = "-x":"assembler-with-cpp":replace xs
replace (x:xs) = x:replace xs
replace [] = []
main = do
args <- getArgs
rawSystem clang $ flags ++ (check args)
clang = "/usr/bin/clang" -- system clang
--clang = "/usr/local/bin/clang" -- clang 3.4/HEAD
--clang = "/usr/local/clang-3.0/bin/clang"
--clang = "/Users/lukexi/bin/clang-3.2/bin/clang"
--clang = "/Users/lukexi/bin/clang-3.3/bin/clang"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment