From: Alice Lee <Alice.Lee@ist.ac.at>
To: "cocci@inria.fr" <cocci@inria.fr>
Subject: [cocci] Can Coccinelle parse files where macros are used as binary operations?
Date: Thu, 12 Mar 2026 15:43:51 +0000 [thread overview]
Message-ID: <274abdf3dbbe4c3e8f1f33fba516c8b3@ist.ac.at> (raw)
[-- Attachment #1: Type: text/plain, Size: 1033 bytes --]
* 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
[-- Attachment #2: Type: text/html, Size: 2933 bytes --]
next reply other threads:[~2026-03-13 10:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 15:43 Alice Lee [this message]
2026-03-13 14:12 ` [cocci] Can Coccinelle parse files where macros are used as binary operations? Julia Lawall
2026-03-16 12:56 ` Alice Lee
2026-03-17 11:31 ` Julia Lawall
2026-03-13 14:25 ` Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=274abdf3dbbe4c3e8f1f33fba516c8b3@ist.ac.at \
--to=alice.lee@ist.ac.at \
--cc=cocci@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox