From mboxrd@z Thu Jan 1 00:00:00 1970 X-Sympa-To: caml-list@inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p73650Bs016211 for ; Wed, 3 Aug 2011 08:05:00 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4EAB3kOE5auLfF/2dsb2JhbABCqFKBQAEBBThAARALGAkWDwkDAgECAUUGDQEHAodqAr9ThkIEmAKLXw X-IronPort-AV: E=Sophos;i="4.67,308,1309730400"; d="scan'208";a="114824671" Received: from 0405ds1-vaer.0.fullrate.dk (HELO fw.fugmann.net) ([90.184.183.197]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 03 Aug 2011 08:04:56 +0200 Received: from [10.0.1.142] (unknown [87.54.60.37]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by fw.fugmann.net (Postfix) with ESMTPSA id 78A9B40017; Wed, 3 Aug 2011 08:04:54 +0200 (CEST) Message-ID: <4E38E4F8.6020300@fugmann.net> Date: Wed, 03 Aug 2011 08:04:40 +0200 From: Anders Fugmann User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110626 Iceowl/1.0b2 Icedove/3.1.11 MIME-Version: 1.0 To: Martin Jambon CC: caml-list@inria.fr References: <4E37EBA3.6040800@fugmann.net> <4E386A65.8080000@ens-lyon.org> In-Reply-To: <4E386A65.8080000@ens-lyon.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Validation-by: af@issuu.com Subject: Re: [Caml-list] filename and line number. 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 >