On Mon, 25 Feb 2019, Timur Tabi wrote:

> I have lots of code that looks like this:
>
> #define MY_ITERATOR(x, y)  for (x=0; x<y; x++)
>
> MY_ITERATOR(v, 20)
> {
>     printf("%i\n", v);
> }
>
> Spatch chokes on this because it thinks MY_ITERATOR() should end with
> a semicolon:
>
> ...
> bad:          MY_ITERATOR(v, 20)
> BAD:!!!!!     {
> bad:               printf("%i\n", v);
> ...
>
> I tried specifying "--undefined MY_ITERATOR", but that did nothing.

If you just want to get it to parse, but don't care about the iterator
behavior, you can put the following in standard.h

#define MY_ITERATOR(x) MACROSTATEMENT

A feature that was considered, but I don't remember whether it was
implemented, was to put

iterator name MY_ITERATOR;

in some rule of the semantic patch.  Then Coccinelle would know about the
looping behavior as well.  But I don't know if that works.

--undefined is for choosing ifdef branches.

julia

> _______________________________________________
> Cocci mailing list
> [email protected]
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to