Thanks for the replies,

Using cppo, would I need to define 'loc' in each file using log, or can it be defined in another module?

If not, I guess the alternative is to create a syntax extenstion that will include Loc.t structure as a parameter to some print function - or add it manually, but I would like to avoid cluttering the code with __LOCATION__ everywhere.

Regards
Anders Fugmann



On 08/02/2011 11:21 PM, Martin Jambon wrote:
On 08/02/11 05:45, Gabriel Scherer wrote:
Finally, Martin Jambon also has its own "cppo" tools mimicking cpp,
which I suppose doesn't rely on camlp4, and has __FILE__ and __LINE__
macros which may be in a more directly exploitable format. I have
never tried it though. See:
   http://martin.jambon.free.fr/cppo.html

That's correct. Thanks for the plug.

Here is an example:

$ cat loc.ml
#define loc (Printf.sprintf "File %S, line %i" __FILE__ __LINE__)

print_endline loc;;
print_endline loc;;

$ ocamlopt -o loc -pp cppo loc.ml; ./loc
File "loc.ml", line 3
File "loc.ml", line 4



Martin



--
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to