4

How can I make use of named constants in ACSL specifications? These constants are either Macros (#define MY_CONST ...) or constant declarations (const int MY_CONST ...). The former does not work since the macros are not expanded by the preprocessor (ACSL specs are C comments), the latter does not because the constants are treated as variables so that some proofs fail. The specification works fine if I replace the named constants with the actual numbers.

Does anyone have a good idea to handle named constants? Thanks in advance

dordow
  • 115
  • 6

2 Answers2

6

In order to expand macros in ACSL specification, you can use the -pp-annot option.

Anne
  • 1,270
  • 6
  • 15
  • I have tried this but got an error "/usr/include/stdc-predef.h:1:[kernel] user error: unexpected token '/'" even when running "frama-c -cpp-extra-args="-I /usr/share/frama-c/libc -nostdinc" -pp-annot " – dordow Mar 21 '14 at 20:52
1

I could resolve the problem with assistance of Pascal Cuoq. It is actually not a problem with frama-c but with gcc. One needs the -fpreprocessed compiler option. My complete command is now:

frama-c -cpp-extra-args="-I `frama-c -print-share-path`/libc" -cpp-extra-args="-nostdinc" -cpp-extra-args="-fpreprocessed </path/to/stdc-predef.h>" -wp -wp-rte -pp-annot myfile.c
dordow
  • 115
  • 6