On Fri, Oct 23, 2020 at 11:00 AM Markus Elfring <markus.elfr...@web.de> wrote:
>
> > I'd like to add a statement after another within a preprocessor expression,
>
> How do you think about to refer to a “#define directive”?

I mean, not specifically in the #define, but anywhere.

(I don't try to patch preprocessor directives with spatch, I use sed for that.)

> >     #define X(a) x(a);
> >
> > (I know the above is not technically correct but it's super common.)
>
> I stumble on understanding difficulties for this information.
> Would you like to clarify the knowledge about correctness a bit more?

A trailing colon in a #define leads to code like this:

    {
        X(1)
        X(2)
        ...
    }

... which of course does not parse.  It would be better to use a do {
... } while (0), or better yet an inline function.  But unfortunately
the above style is very common.

On Fri, Oct 23, 2020 at 11:11 AM Julia Lawall <julia.law...@inria.fr> wrote:

> I don't think he is asking that.  He means, if the call to x happens to be
> in a macro definition, how can he ensure that the transformed code treats
> newlines in the right way.

Yes, exactly. :)
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to