caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] newbie question: How to do conditional compilation?
@ 2001-09-18  4:02 Gao katie
  2001-09-18  8:06 ` Daniel de Rauglaudre
  0 siblings, 1 reply; 2+ messages in thread
From: Gao katie @ 2001-09-18  4:02 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]


Can anyone tell me how to do conditional compilation in Ocaml?

#ifdef DEBUG

...

#else

...

#endif

Thanks.

 



---------------------------------
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information inYahoo! News.

[-- Attachment #2: Type: text/html, Size: 462 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] newbie question: How to do conditional compilation?
  2001-09-18  4:02 [Caml-list] newbie question: How to do conditional compilation? Gao katie
@ 2001-09-18  8:06 ` Daniel de Rauglaudre
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel de Rauglaudre @ 2001-09-18  8:06 UTC (permalink / raw)
  To: Gao katie; +Cc: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-09-18  8:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-18  4:02 [Caml-list] newbie question: How to do conditional compilation? Gao katie
2001-09-18  8:06 ` Daniel de Rauglaudre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).