-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using named constants in cn
specs
#230
Comments
One workaround that can be used at the moment is define a constant function, for example: int c_INT_MAX() { return INT_MAX; } |
Precisely as you identify, because of the C pre-processor and comments interaction. Perhaps one for the list of engineering-y/polish features to add. Anyways, below is the idiomatic way to do something like this.
|
I am going to close this issue since the lack of explanation is noted in rems-project/cn-tutorial#4 and also it's not really something CN (or even Cerberus) can do much about. Pre-processor shenanigans like macros are a tricky problem to solve in the general case (a Clang plugin would be required: https://github.com/rems-project/c-tree-carver/blob/main/cpp/src/reachability_analyzer.hpp) . Perhaps a simple workaround would be to run a simple grep over a project, gather the constants in a temporary header file, and |
It is common to use
#define
to name various constants in C, but it looks like these cannot be referenced in CN specifications. I am guessing that this happens because CN specs are comments and the preprocessor does not expand macros in comments.Is there a known work around for this?
The text was updated successfully, but these errors were encountered: