Closed GoogleCodeExporter closed 9 years ago
You are making two main mistakes here:
1) nullcBuild function cleans the nullc compiler, linker and executer state, so
with every call, you receive a clean environment to run nullc code.
nullc main use case is to build your code once, call nullcRun once to execute
global code and then call nullc functions using nullcRunFunction calls.
2) nullcSetGlobal will set internal nullc variable value to the value of your
C++ variable, but it will not save the link between them. To do that, you
should make a reference to an int in nullc code and set its value to a pointer
to your variable.
Here is an example of code that "binds" a variable to nullc:
nullcInit("Modules/");
int value = 2;
int *valuePtr = &value;
nullres good = nullcBuild("int ref value; int get(){ return *value; } void
set(int x){ *value = x; }");
// Run global code
nullcRun();
// Set global reference to C++ variable
nullcSetGlobal("value", &valuePtr);
printf("value equals %d\n", value);
// Get the variable value as seen from nullc
if(nullcRunFunction("get"))
printf("*value in nullc equals %d\n", nullcGetResultInt());
// Change the variable value from nullc
if(nullcRunFunction("set", 5))
printf("value is now %d\n", value);
nullcTerminate();
Original comment by Where...@gmail.com
on 26 Jun 2012 at 9:22
Original issue reported on code.google.com by
happygre...@gmail.com
on 31 May 2012 at 12:00