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

Alice Lee <[email protected]> Thu, 12 Mar 2026 15:43:51 +0000
Newsgroups fr.inria.cocci
Message-ID <[email protected]>
  *   Hello,

I am trying to use Coccinelle to search C codebases (I split up my questions to make the threads more clear) and I am struggling to understand the scope of the --macro-file argument.
  *
  *   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 was unable to get a small example to work, so I assume that I can define the macro but then there is no preprocessing to drop code. If I'm not overlooking something, how would you recommend I parse a file including these lines and then uses LS/RS as binary operators<https://git.musl-libc.org/cgit/musl/tree/src/string/memcpy.c#n50>:
  *

  *
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define LS >>
#define RS <<
#else
#define LS <<
#define RS >>
#endif

I'm especially confused by this example because Coccinelle also cannot parse a version in which I remove the code above and put one of the pairs of defines in the macro definition file.

Thank you,
Alice Lee