<font face="arial,helvetica,sans-serif">Hi all.</font><div><font face="arial,helvetica,sans-serif">I would like to declare a function that takes a function pointer as an argument.</font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">In C, it would be :</font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">void execute(char (*func)(void*), void *param)</font></div>
<div>
<font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">So, in my compiler, I have :</font></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space: pre; "> </span>std::vector<const Type *> cbFPtrArgs(1, Type::getInt8PtrTy(C));</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre"> </span>FunctionType * cbFPtrTy = FunctionType::get(Type::getInt8Ty(C), cbFPtrArgs, false);</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre"> </span>Function * func = cast<Function>(M->getOrInsertFunction(fName, Type::getInt32Ty(C), cbFPtrTy, Type::getInt8PtrTy(C), (Type *)0));</font></div>
<div style="font-family: arial, helvetica, sans-serif; "><br></div><div style="font-family: arial, helvetica, sans-serif; ">But then I get an error form LLVM :</div><div><font class="Apple-style-span" face="'courier new', monospace">/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.</font></div>
<div style="font-family: arial, helvetica, sans-serif; "><br></div><div style="font-family: arial, helvetica, sans-serif; ">It seems that a FunctionType is not a valide function argument type.</div><div style="font-family: arial, helvetica, sans-serif; ">
Does someone know what am I missing ?</div><div style="font-family: arial, helvetica, sans-serif; "><br></div><div style="font-family: arial, helvetica, sans-serif; ">Thank you very much for your help.</div><meta http-equiv="content-type" content="text/html; charset=utf-8"></div>
<div><br>-- <br><font face="'courier new', monospace" color="#666666"><div><br></div><div> <img src="http://img690.imageshack.us/img690/469/signatureit.png"><br></div></font><br>
</div>