Re: [cocci] Can Coccinelle parse files where macros are used as binary operations?

Markus Elfring <[email protected]> Fri, 13 Mar 2026 15:25:37 +0100
Newsgroups fr.inria.cocci
Message-ID <[email protected]>
> I am trying to use Coccinelle to search C codebases (…)

Nice …


> and I am struggling to understand the scope of the --macro-file argument.

https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/233b5ceb1d5a701fb270ebdf0a9bd6be0a6ce53b/docs/manual/spatch_options.tex#L409-412


> Can macros used with #if in the source code be defined in a file passed with --macro-file, and then the right sections of source code are ignored?

I suggest to reconsider corresponding expectations in more detail.

1. Some developers would like to expect that the Coccinelle software



> # Can macros used with #if in the source code be defined in a file passed with --macro-file, and then the right sections of source code are ignored?

1. Some developers would like to expect that the Coccinelle software
   can handle source files also without extra preprocessing.

   But it was discovered that implementation details are still waiting on
   corresponding clarifications.

   Exclude macro calls from searches for function implementations
   2024-10-28
   https://github.com/coccinelle/coccinelle/issues/381

2. Software components can be improved accordingly.

   Improve support for the handling of #if conditions
   2022-10-29
   https://github.com/coccinelle/coccinelle/issues/293


Regards,
Markus