[Libguestfs] [PATCH] generator: Sort the structs.

Richard W.M. Jones rjones at redhat.com
Tue Jul 1 15:52:29 UTC 2014


On Tue, Jul 01, 2014 at 05:27:42PM +0200, Pino Toscano wrote:
> On Tuesday 01 July 2014 16:16:18 Richard W.M. Jones wrote:
> > Sort the structs when generating code.  Since the structs are
> > logically indepedent of each other, this should have no effect except
> > to make generated files list the structs in a different order.
> > 
> > However this also fixes the following build problem:
> > 
> >   File "convert_linux.ml", line 322, characters 43-50:
> >   Error: This expression has type G.stat = Guestfs.stat
> >     but an expression was expected of type G.dirent = Guestfs.dirent
> > 
> > It turns out the OCaml bindings don't like the fact that we have
> > two structs with a common field name (dirent.ino and stat.ino).
> > 
> > In OCaml < 4.01, this means that any attempt to reference stat.ino
> > would fail because dirent.ino appears second in the file, overriding
> > stat.ino.
> 
> So that means that with such OCaml versions both the .ino members cannot 
> be used at the same time?

Yup.  Luckily we don't use `dirent.ino'.

> > In OCaml >= 4.01 the compiler now uses some disambiguation rules based
> > on the known types to resolve this problem.
> 
> Patch seems good to me.

Thanks - I will push it in a moment.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the Libguestfs mailing list