<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>You're trying to apply an operation on a Type to a Value; that's no good, as you say. So you want the return type of the <i>type of the function</i>. But the function value itself is of type %function*, so you have to 'dereference' the type first:</div><div><br></div><div>LLVMGetReturnType(LLVMGetElementType(LLVMTypeOf(F)))</div><div><br></div><div>This may help to clarify: <a href="http://llvm.org/docs/ProgrammersManual.html#coreclasses">http://llvm.org/docs/ProgrammersManual.html#coreclasses</a></div><div><br></div><div><div>On May 22, 2008, at 10:07, Syoyo Fujita wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi LLVM-ers,<br><br>I am trying to get a return type of a function(from bitcode file) with LLVM-C API, but there seems no appropriate API to do that.<br><br>I've tried to do that with following code,<br><br>----<br><br> LLVMModuleRef           M;<br>LLVMMemoryBufferRef     MemBuf;<br>LLVMValueRef            F;         // Function<br>LLVMTypeRef             RetTy;     <br>char                   *ErrStr;<br><br>//<br>// -- Load shader module<br> //<br>ret = LLVMCreateMemoryBufferWithContentsOfFile(<br>         input,<br>        &MemBuf,    // [out]<br>        &ErrStr);   // [out]<br><br>ret = LLVMParseBitcode(<br>         MemBuf,<br>        &M,         // [out]<br>         &ErrStr);   // [out]<br><br>F = LLVMGetFirstFunction(M);<br><br>RetTy = LLVMGetReturnType(F);   // NG! Can't do this<br><br>----<br><br>How can I do that? <br>(I am using HEAD version of llvm)<br><br>And is there a tutorial or document for LLVM C API?<br> <br><br>Thanks in advance. _______________________________________________<br>LLVM Developers mailing list<br>LLVMdev@cs.uiuc.edu         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br><div> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><br class="Apple-interchange-newline"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><br class="khtml-block-placeholder"></div>— Gordon<br class="Apple-interchange-newline"></span></span></span></span></span></div></span> </div><br></body></html>