There are a number of problems in your example including a couple of fairly fundamental C errors.On Sep 26, 2011, at 2:39 PM, Bradley Pietrzak wrote: Thank you again for your responses. Unfortunately, I have encountered another problem, this time involving code that has been escaped to C. The new version of my program is shown below. Without the re-entrant option, the code runs perfectly fine. With the re-entrant option, however, I am met with several errors. The SNL user's manual says that the SNC automatically refers to variables in the struct UserVar by running the code " pVar->xxx", but that such references have to be handled manually for escaped C code. How do I handle such situations manually?
/* Sample Program */ program sncExample
option +r; /* reentrant */
float i;
float pv; assign pv to "testioc:magnet{mag}";
%{
void helloWorld(i) { <<<<<==== Here you've not specified a type for 'i', so the compiler assumes it to be an 'int'. printf("Hello World! You have just called a C function, and the variable i is %5.1f \n", i); <<<<====== But here you tell printf that the argument being passed to be printed is a double-precision floating point value.
}
}%
ss ss1 {
state one { when() { i = 1; %% helloWorld(i); <<<<===== Reentrant state sets have variables placed into a structure so you need to say %% helloWorld(pVar->i); -- see the SNL manual for details pv = 1; pvPut(pv); sleep(1); } state two }
state two {
when () { i = 2; %% helloWorld(i); pv = 2; pvPut(pv); sleep(1); } state one }
}
Thanks,
Brad Pietrzak
|