eng2019
eng2019

Reputation: 53

How cbmc works with c header?

If I have a c file that contains more than one function, and I want to run the cbmc with z3 solver on the preprocessed version of the program (using gcc) and there are some other files(c files) in the header section. How will the cbmc see those files? because I tried to run it and he gives some errors about some variables as not declared where it's, in fact, they are declared in one of the header files.

could anyone explain how this works?

UPDATE:

int test(int x) {
for (int i = 2; i < sqrt(x); i++) {
    if (x%i == 0)
        return 0;
}

First of all, I preprocess the program using gcc

Then parse the program by pycparser

then instrument (add print statement after 4 to see the value of x)

Then I ran the cbmc on the instrumented version of file and I got this error: function `sqrt' is not declared

Upvotes: 0

Views: 178

Answers (1)

virolino
virolino

Reputation: 2227

You should include in the project all the files referenced by the header files. It is not enough to include only the right header(s), if the associated .c file(s) is not available.


Your sample code MUST have these lines also:

    else
    {
        return 1;
    }
}

Upvotes: 0

Related Questions