Reputation: 16635
In a library I'm writing I need to use CPP
to choose between two blocks of code depending on whether my user is compiling with LLVM or the native code gen. Is there a way to detect this in the .cabal
file and do something like
library
-- not real:
if backend(llvm)
CPP-Options: -DUSING_LLVM
Or maybe it's even possible to detect arbitrary flags passed to GHC (instead of just -fllvm
)?
Upvotes: 1
Views: 146
Reputation: 16635
Ah, I forgot to check the GHC docs. GHC defines a macro __GLASGOW_HASKELL_LLVM__
which is defined when -fllvm
was specified (and can be used to check llvm version as well):
Upvotes: 1