Version française
Home     About     Download     Resources     Contact us    
Browse thread
Conditional compilation
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pietro Abate <Pietro.Abate@p...>
Subject: Re: [Caml-list] Conditional compilation
On Mon, Aug 17, 2009 at 11:26:52PM -0300, Andre Nathan wrote:
> On Mon, 2009-08-17 at 22:00 -0400, Edgar Friendly wrote:
> > Is there a better way to do this?  The path I'm following is looking
> > very byzantine compared to C's [-DFOO] + [#ifdef FOO].
> In ospec I use

In my projects I sometimes used directly cpp (Lazy me!). Today I
realized that is not such a good idea cpp interprets c++ comments - like
"\\" - and removes them from your code. For example is you compile the
following empty program with 
> ocamlbuild -pp "cpp" test.native

--- test.ml ---
(* http://localhost.org *)
---------------

you will get an error like :

File "test.ml", line 2, characters 5-7:
Error: Comment not terminated
Command exited with code 2.

that is the result of the preprocessing step :

> cpp test.ml 
# 1 "test.ml"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.ml"

     (* http:
------------------   

Just to say that "-pp camlp4o Camlp4MacroParser.cmo" is a safer choice
... And maybe I was the only fool using cpp with ocaml ...

> 
>   -pp "camlp4o Camlp4MacroParser.cmo -D FOO"
> 
> which can then be tested in the code with
> 
> IFDEF FOO THEN
>   ...
> END
> 
> 
> HTH,
> Andre
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

-- 
----
http://en.wikipedia.org/wiki/Posting_style