[LLVMdev] FunctionType as a function argument

Salomon Brys salomon.brys at gmail.com
Mon Nov 29 10:37:34 PST 2010


Hi all.
I would like to declare a function that takes a function pointer as an
argument.
In C, it would be :

void execute(char (*func)(void*), void *param)

So, in my compiler, I have :
std::vector<const Type *> cbFPtrArgs(1, Type::getInt8PtrTy(C));
 FunctionType * cbFPtrTy = FunctionType::get(Type::getInt8Ty(C), cbFPtrArgs,
false);
 Function * func = cast<Function>(M->getOrInsertFunction(fName,
Type::getInt32Ty(C), cbFPtrTy, Type::getInt8PtrTy(C), (Type *)0));

But then I get an error form LLVM :
/home/salomon/AppSRC/LLVM/release_28/lib/VMCore/Type.cpp:456:
llvm::FunctionType::FunctionType(llvm::Type const *, std::vector<llvm::Type
const *> const &, bool): Assertion `isValidArgumentType(Params[i]) && "Not a
valid type for function argument!"' failed.

It seems that a FunctionType is not a valide function argument type.
Does someone know what am I missing ?

Thank you very much for your help.

--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101129/dedbf0ce/attachment.html>


More information about the llvm-dev mailing list