<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><blockquote type="cite">On Tue, Jul 13, 2010 at 12:46 PM, Frank Fuchs <<a href="mailto:fk.fuchs@googlemail.com">fk.fuchs@googlemail.com</a>> wrote:<br></blockquote><blockquote type="cite"><blockquote type="cite">Here's the error message:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">main.cpp:5:4: error: use of undeclared identifier 'known'<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">      i=known(i);<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">        ^<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">1 error generated.<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Right... the frontend has no clue what mapping you're doing in the backend.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite">also defining "known" as: extern "C" int known(int);    does not solve the issue, the error is then:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">LLVM ERROR: Program used external function 'known' which could not be resolved!<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I have a feeling you're not actually adding a mapping for "known"; try<br></blockquote><blockquote type="cite">dumping the module.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">-Eli<br></blockquote><br>Ok here is the output of Mod->dump() called right before runAsFunctionMain(...). I am referring to the example with the extern "C" int known(int) declaration!  <br><br>; ModuleID = 'test.cpp'<br>target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"<br>target triple = "x86_64-apple-darwin10.0.0"<br><br>@.str = private constant [16 x i8] c"Ext. CALL %d \0A\0A\00" ; <[16 x i8]*> [#uses=1]<br><br>define i32 @main() ssp {<br>entry:<br> %retval = alloca i32, align 4                   ; <i32*> [#uses=1]<br> %i = alloca i32, align 4                        ; <i32*> [#uses=4]<br> store i32 0, i32* %retval<br> store i32 1, i32* %i<br> %tmp = load i32* %i                             ; <i32> [#uses=1]<br> %call = call i32 @known(i32 %tmp)               ; <i32> [#uses=1]<br> store i32 %call, i32* %i<br> %tmp1 = load i32* %i                            ; <i32> [#uses=1]<br> %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([16 x i8]* @.str, i32 0, i32 0), i32 %tmp1) ; <i32> [#uses=0]<br> ret i32 0<br>}<br><br>declare i32 @known(i32)<br><br>declare i32 @printf(i8*, ...)<br><br>declare i32 @known1(i32)<br><br><br>I'm not sure how to interpret this ... but the "known1" seems to be the mapped function, while "known" is the extern "C" declared one (checked that by renaming "known" in test.cpp). ... End of knowledge :)<br><br>-Frank</body></html>