<div dir="ltr">Hi,<div><br></div><div>I compiled my ECL lisp functions with asdf:make-build into a library.</div><div><br></div><div>Some functions depend on the value of a global variable which has to be set in the code using the library.</div>
<div><br></div><div>But when changing the value of the global variable in the code using the library, the library functions still use the old value...</div><div><br></div><div>What can I do?</div><div><br></div><div>===</div>
<div><br></div><div>Here a simplified example using a global integer variable:</div><div><br></div><div>The global variable is declared in a header file</div><div><br></div><div>--- context.h ---</div><div><div>extern int global_int;</div>
</div><div>---</div><div><br></div><div>and defined in </div><div><br></div><div>--- context.cpp ---</div><div><div>int global_int = 123;</div></div><div>---</div><div><br></div><div>It is used in the following lisp function (test) defined in the library:</div>
<div><br></div><div>---</div><div><div>(ffi:clines "#include \"context.h\"")</div></div><div><div>(defun test () (ffi:c-inline () () :void "myprint(global_int);"))</div></div><div>---</div><div>
<br></div><div>When printing the value from the main program, which includes the header file context.h as well, changing the value to 456 and printing again works as expected:</div><div><br></div><div>---</div><div><div>#include "context.h"</div>
</div><div>myprint(global_int);<br></div>global_int = 456;<div>myprint(global_int);</div><div>---</div><div><br></div><div>results in the following being printed:</div><div><br></div><div>---</div><div>123</div><div>456</div>
<div>---</div><div><br></div><div>But when evaluating (test) before and after the value is changed, in both cases the original value is printed:</div><div><br></div><div>---</div><div>123</div><div>123</div><div>---</div>
<div><br></div><div>What can I do to make the lisp function defined in the library use the new updated value?</div><div><br></div><div>Thanks,</div><div><br></div><div>Dietrich</div><div><br></div><div><br></div><div><br>
</div></div>