Question

I am using jspin and trying to include stdio.h library within c_code expression:

c_code
{
    #include <stdio.h>
}

However, I get the following error:

spin: error: No file 'stdio.h'

I have checked directory where mingw is installed and it has stdio.h inside. Thus, I suppose, it is all about wrong paths. How can I set include path in jspin?

Was it helpful?

Solution

Try:

c_decl {
  \#include <stdio.h>
}

The \# is the critical part (Spinroot.com for c_decl). Also, use c_decl{} because .h files contain no code.

[edit] Regarding fprintf() not showing output; I can't say I know the reason. I tried your particular code. Here is the result:

ebg@ebg$ rm /tmp/foo.bar
ebg@ebg$ spin -a test.pml
ebg@ebg$ gcc -o test pan.c
ebg@ebg$ ./test
hint: this search is more efficient if pan.c is compiled -DSAFETY

(Spin Version 6.2.4 -- 21 November 2012)
    + Partial Order Reduction

Full statespace search for:
    never claim             - (none specified)
    assertion violations    +
    acceptance   cycles     - (not selected)
    invalid end states  +

State-vector 12 byte, depth reached 2, errors: 0
        3 states, stored
        0 states, matched
        3 transitions (= stored+matched)
        0 atomic steps
hash conflicts:         0 (resolved)

Stats on memory usage (in Megabytes):
    0.000   equivalent memory usage for states (stored*(State-vector + overhead))
    0.292   actual memory usage for states
  128.000   memory used for hash table (-w24)
    0.534   memory used for DFS stack (-m10000)
  128.730   total actual memory usage


unreached in init
    (0 of 2 states)

pan: elapsed time 0 seconds
ebg@ebg$ cat /tmp/foo.bar 
some str

Here is the code I used:

c_decl {
  \#include <stdio.h>
}

init {
  c_code {
    FILE *file;

    file = fopen ("/tmp/foo.bar", "a+");
    fprintf (file, "%s", "some str");
    fclose (file);
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top