[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MirageOS-devel] Compile error when using cstruct



On 16 Jul 2014, at 13:01, Dave Scott <Dave.Scott@xxxxxxxxxx> wrote:

> Hi,
> 
> On 16 Jul 2014, at 12:48, Tom Brown <tom.jrbrown@xxxxxxxxx> wrote:
> 
>> Hi all,
>> 
>> I receive the following error when I compile a Mirage application, exactly 
>> on the lines that I have cstruct definitions:
>> 
>> Parse error: [label_expr_list] or [expr level .] expected after "{" (in 
>> [expr])
>> Preprocessing error on file lib/input.ml
>> Error while running external preprocessor
>> Command line: camlp4 '-I' '/usr/lib/ocaml/camlp4' '-I' 
>> '/home/ocaml/.opam/system/lib/lwt' '-I' '/home/ocaml/.opam/system/lib/lwt' 
>> '-parser' 'o' '-parser' 'op' '-printer' 'p' 'lwt-syntax-options.cma' 
>> 'lwt-syntax.cma'  'lib/input.ml' > /tmp/ocamlppf271c4
>> 
>> Would you please help me in finding the problem?
> 
> It looks like the cstruct.syntax extension isn’t loaded. I normally add a 
> line to my _tags file at the bottom like this:
> 
> <foo.ml>: pkg_cstruct.syntax, syntax_camlp4o

You don't have to edit the _tags file manually if using the `mirage` CLI tool.  
In the mirage/mirage-www/src/config.ml, we activate the `cow.syntax` XML 
extension as follows:

let main =
  let libraries = [ "cow.syntax"; "cowabloga" ] in
  let packages = [ "cow"; "cowabloga" ] in
  foreign ~libraries ~packages "Dispatch.Main"
    (console @-> kv_ro @-> kv_ro @-> http @-> job)

let () =
  register "www" [
    main $ default_console $ fs $ tmpl $ server
  ]


You should be able to do the same with cstruct.  Just pass "cstruct.syntax" for 
the libraries (which refers to the ocamlfind command-line), and "cstruct" for 
the packages variable (which refers to OPAM packages, that usually contain 
multiple ocamlfind packages).

I've created https://github.com/mirage/mirage/issues/271 to track whether we 
should activate cstruct by default from the CLI tool.

-anil
_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.