[llvm-commits] llvm-c/Target.h SWIG friendliness
James Y Knight
foom at fuhm.net
Thu Dec 17 15:05:09 PST 2009
Without this patch, SWIG chokes on llvm-c/Target.h, as, if you don't use #include files, it appears to have duplicate #defines. (SWIG doesn't follow #include when looking for functions/enums/etc to wrap). Since LLVM-C's main purpose is to generate bindings, it seems like a good idea to have it not cause SWIG to barf.
Of course, even with this patch, SWIG won't notice the LLVMInitialize*Target and LLVMInitialize*TargetInfo functions, but at least it's not completely failing. Perhaps it would be a better idea to pre-expand all these definitions, rather than using fancy #include tricks with llvm/Config/Targets.def at all, but this works well enough for me.
--- Target.h~ 2009-11-17 13:58:45.000000000 -0500
+++ Target.h 2009-12-17 17:36:55.675913000 -0500
@@ -35,9 +35,11 @@
/* Declare all of the target-initialization functions that are available. */
#define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetInfo();
#include "llvm/Config/Targets.def"
+#undef LLVM_TARGET
#define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target();
#include "llvm/Config/Targets.def"
+#undef LLVM_TARGET
/** LLVMInitializeAllTargetInfos - The main program should call this function if
it wants access to all available targets that LLVM is configured to
@@ -45,6 +47,7 @@
static inline void LLVMInitializeAllTargetInfos() {
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
#include "llvm/Config/Targets.def"
+#undef LLVM_TARGET
}
/** LLVMInitializeAllTargets - The main program should call this function if it
@@ -53,6 +56,7 @@
static inline void LLVMInitializeAllTargets() {
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
#include "llvm/Config/Targets.def"
+#undef LLVM_TARGET
}
/** LLVMInitializeNativeTarget - The main program should call this function to
More information about the llvm-commits
mailing list