added casts and conditional inlude for LLVM/Clang compilation