From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA19644; Tue, 18 Sep 2001 10:06:30 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA20032 for ; Tue, 18 Sep 2001 10:06:30 +0200 (MET DST) Received: from verdot.inria.fr (verdot.inria.fr [128.93.11.7]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f8I86R927600; Tue, 18 Sep 2001 10:06:27 +0200 (MET DST) Received: (from ddr@localhost) by verdot.inria.fr (8.9.3/8.9.3) id KAA22965; Tue, 18 Sep 2001 10:06:27 +0200 Date: Tue, 18 Sep 2001 10:06:27 +0200 From: Daniel de Rauglaudre To: Gao katie Cc: caml-list@inria.fr Subject: Re: [Caml-list] newbie question: How to do conditional compilation? Message-ID: <20010918100627.C22805@verdot.inria.fr> References: <20010918040228.8243.qmail@web10102.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010918040228.8243.qmail@web10102.mail.yahoo.com>; from katiegao@yahoo.com on Mon, Sep 17, 2001 at 09:02:28PM -0700 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, On Mon, Sep 17, 2001 at 09:02:28PM -0700, Gao katie wrote: > Can anyone tell me how to do conditional compilation in Ocaml? > #ifdef DEBUG > ... > #else > ... > #endif 1/ You can use camlp4. Compile either with ocamlc -pp "camlp4o pa_ifdef.cmo" or with ocamlc -pp "camlp4o pa_ifdef.cmo -DDEBUG" In your code, you can then use "ifdef DEBUG ... else ... end" in position of expression, or "ifdef ... end" in position of structure item (toplevel phrase, if you prefer). You can also use "define" (but without parameters: "define DEBUG", not "define DEBUG xxx") 2/ Another solution is to use /lib/cpp, the C preprocessor. I think that you can use it in only one command with the ocamlc parameter -pp: ocamlc -pp "/lib/cpp" ocamlc -pp "/lib/cpp -DDEBUG" -- Daniel de RAUGLAUDRE daniel.de_rauglaudre@inria.fr http://cristal.inria.fr/~ddr/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr