On Fri, 3 Jun 2011, Francis Galiegue wrote:
> On Fri, Jun 3, 2011 at 00:17, Ajay Panyala <[email protected]> wrote:
> >
> > Hello,
> >
> > I am new to Coccinelle. I am trying to write a simple transformation
> > that changes memory allocation of arrays from static to dynamic.
> > Example:
> > double a[x][y];
> > should be transformed to
> > double (*a)[y] = new double[x][y]; --> the transformed code is C++,
>
> Which is very probably why this doesn't work: Coccinelle knows C only,
> and C++ only a very little. It doesn't like "new" ;)
>
> Maybe you can try to create a macro file with the simple line:
>
> ----
> #define new
> ----
>
> and then run spatch with -macro_file_builtins /path/to/this/file, but
> I don't even know whether that will work.
No, it won't work. The problem is that the parser of C code knows C++ but
the parser of SmPL (matching) code does not. The only possibility is to
create new(...) and then use some other tool (or just a macro) to get rid
of the parentheses afterwards.
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)