Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Conditional compilation in interface files
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Julian Brown <brown@c...>
Subject: [Caml-list] Conditional compilation in interface files
Hi,

I have a program which is written in two parts, one of which works OK,
and one of which isn't finished yet. These two parts are intermingled
somewhat, but I'd like to be able to conditionally compile a version of
the working part (on its own) with the hooks into the other part
removed, so I can release it.

My ideas so far are:

 * Use -pp with the C preprocessor (but it gets confused by some Ocaml
 syntax).

 * Use camlp4 with pa_macro.cmo, but I can't get it working!

In particular, I can't get pa_macro.cmo to conditionally compile bits
of interface files. I have this:

IFDEF SIMONLY THEN
class services :
  object
    method getdescriptor : int -> Unix.file_descr
    method getdishelp : disassembler_helper
    method insertdescriptor : int -> Unix.file_descr -> unit
    method killdescriptor : int -> unit
    method newdescriptor : Unix.file_descr -> int
    method querydescriptor : int -> bool
    method getoptlimit : int option
    method setoptlimit : int option -> unit
    method testoptok : bool
    method bumpopt : unit
  end
ELSE
class services :
  object
    method getallocator : Alloc.zone
    method getindexer : Index.indexer
    method getprofiler : Profiler.profiler
    method getdescriptor : int -> Unix.file_descr
    method getdishelp : disassembler_helper
    method insertdescriptor : int -> Unix.file_descr -> unit
    method killdescriptor : int -> unit
    method newdescriptor : Unix.file_descr -> int
    method querydescriptor : int -> bool
    method getoptlimit : int option
    method setoptlimit : int option -> unit
    method testoptok : bool
    method bumpopt : unit
  end
ENDIF;;

This gives me:

Parse error: [interf] expected after [sig_item_semi] (in [interf])

The docs don't appear to suggest to me that it should work even. Is
there a better way of doing this? (And do I have to use the revised
syntax for this extension?)

I'd like to keep my development code monolithic for now, so I don't
really want to separate the unfinished bit into a shared library or
anything like that.

Any hints appreciated! I'm using Ocaml 3.07, 3.08.0 behaves the same for
this.

Cheers,

Julian

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners