From: Peter J. <pe...@jo...> - 2004-02-03 09:34:26
|
Pietro Abate wrote: > Hi all, > I want to distribute extlib with my project and to do so I added a > Makefile to it. When compiling it on debian unstable (ocaml 3.07) > everything it's ok. When I try to compile the same code, with the same > makefile and ocaml 3.06 (debian woody) I get a complain about extString: > > [...] > ocamlc -c extString.mli > ocamlc -c extString.ml > The implementation extString.ml does not match the interface extString.cmi: > Modules do not match: > sig > exception Invalid_string > external length : string -> int = "%string_length" > external get : string -> int -> char = "%string_safe_get" > external set : string -> int -> char -> unit = "%string_safe_set" > external create : int -> string = "create_string" > val make : int -> char -> string > val copy : string -> string > > [...] > > val lowercase : string -> string > val capitalize : string -> string > val uncapitalize : string -> string > type t = string > val compare : t -> t -> int > end > The field `compare' is required but not provided > The field `t' is required but not provided > make[1]: *** [extString.cmo] Error 2 > #> > > my naive solution was to add > type t = string > let compare = compare in the extString.ml file. > > now it compiles with ocmal 3.06, but it complains with 3.07 because > there's a dup definition... I know it sounds silly, but are you sure you're using version 3.06? The reason I ask is that this problem would make perfect sense in 3.04, because the compare and t fields in the standard String library were not present in that version. Also, Debian isn't distributing 3.06 at the moment - stable is 3.04, testing and unstable are 3.07. At any rate, since you're using OCamlMakefile it's pretty easy to work round this, if you're willing to use a non-standard ExtLib. Add conditional compilation directives from your preprocessor of choice using some suitable conditional symbol around the definitions of t and compare in extString.ml, and a (*pp foo *) directive at the top of that file to invoke that preprocessor. Then write a simple configure script that tries to compile a test that depends on String.compare and sets PPFLAGS to define that symbol if it fails. HTH |