On Mon, 25 Nov 2019, David Frey wrote: > Hi, > > I'm trying to write a .cocci file to transform all calls to a function > "f(ex)" to something like this: > > #ifdef USE_F > f(ex) > #else > g(ex) > #endif > > The function has this signature: > bool f(int x); > > This is the patch that I tried to use: > @@ > expression ex; > @@ > +#ifdef USE_F > f(ex) > +#else > +g(ex) > +#endif > > > This is the result of running it: > $ spatch --show-c --sp-file test.cocci test.c > init_defs_builtins: /usr/bin/../lib/coccinelle/standard.h > plus: parse error: > File "test.cocci", line 7, column 1, charpos = 50 > around = 'g', > whole content = +g(ex) > > What is wrong with the patch above?
Coccinelle doesn't currently support adding ifdefs on expressions, only on statements. You could try for some typical usage contexts, like +ifdef... x = f(ex); +#else +x = g(ex); +#endif julia _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
