<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I'm trying to pass a function pointer to the LLVM interpreter, but when I print it in the llvm function it is null. I'm using the C API.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Here's the relevant code (It's in D):</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://pastebin.com/hSbdDpfa" id="LPlnk461867">https://pastebin.com/hSbdDpfa</a><br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
and here's the output:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>define void @fp_pass_test(void ()*) {<br>
</span>
<div>entry:<br>
</div>
<div> %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @0, i32 0, i32 0), void ()* %0)<br>
</div>
<div> call void %0()<br>
</div>
<div> ret void<br>
</div>
<div>}<br>
</div>
<div>passed ptr: 4142ddb0<br>
</div>
<div>unwrapped ptr: 4142ddb0<br>
</div>
<div>received ptr: 0<br>
</div>
<div>Program exited with code -11<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Does anyone know why the pointer would become null after passing it through LLVMRunFunction?</div>
<div><br>
</div>
<div>Best Regards</div>
<div>Hakan</div>
<span></span></div>
</body>
</html>