From: Pierrick Couderc <pierrickcouderc@gmail.com>
To: Gustave Nimant <gustave.nimant@free.fr>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] How to get the path of Filename.current_dir_name
Date: Mon, 10 Oct 2016 11:01:13 +0200 [thread overview]
Message-ID: <CA+gYG2vrea94tCP1ijAusN8JyMvmO6gmR5wPvPnf58DE++EZAw@mail.gmail.com> (raw)
In-Reply-To: <57FB559A.1070302@free.fr>
[-- Attachment #1: Type: text/plain, Size: 1380 bytes --]
>
> __FILE__ returns the name of the module, not the name and absolute path.
Actually, it returns the exact path given to the compiler. For example :
$ cd /tmp
$ echo 'Printf.printf \"File path: %s\n%!" __FILE__;;' > t.ml
Then compiled and executed:
$ ocamlc t.ml && ./a.out
> File path: t.ml
$ ocamlc /tmp/t.ml && ./a.out
> File path: /tmp/t.ml
$ ocamlc ../tmp/../tmp/t.ml && ./a.out
> File path: ../tmp/../tmp/t.ml
2016-10-10 10:47 GMT+02:00 Gustave Nimant <gustave.nimant@free.fr>:
> On 05/10/2016 16:34, Pierrick Couderc wrote:
>
>
> If I understood correctly, it is more about the directory of the module at
> compile time.
>
> the absolute path of the module at compile time.
>
> One (hackish) way to do it is with the value __FILE__ in Pervasives (see
> http://caml.inria.fr/pub/docs/manual-ocaml/libref/
> Pervasives.html#6_Debugging for some compile time constant used for
> debugging).
> It simply returns the path of the .ml given to the compiler, not an
> absolute path (except if you called the compiler on an absolute path, of
> course).
>
> __FILE__ returns the name of the module, not the name and absolute path.
> I do not understand what do you mean by "except if you called the compiler
> on an absolute path, of course"
> could you please give me more details about calling the compiler on an
> absolute path ?
>
> Thanks
> Gustave
>
[-- Attachment #2: Type: text/html, Size: 3016 bytes --]
next prev parent reply other threads:[~2016-10-10 9:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-27 15:04 [Caml-list] [ANN] BAP 1.0.0 Ivan Gotovchits
2016-10-04 13:30 ` Anil Madhavapeddy
2016-10-05 14:11 ` [Caml-list] How to get the path of Filename.current_dir_name Gustave Nimant
2016-10-05 14:22 ` Gabriel Scherer
2016-10-05 14:34 ` Pierrick Couderc
2016-10-10 8:47 ` Gustave Nimant
2016-10-10 9:01 ` Pierrick Couderc [this message]
2016-10-10 10:26 ` Gustave Nimant
2016-10-05 14:35 ` Daniel Bünzli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+gYG2vrea94tCP1ijAusN8JyMvmO6gmR5wPvPnf58DE++EZAw@mail.gmail.com \
--to=pierrickcouderc@gmail.com \
--cc=caml-list@inria.fr \
--cc=gustave.nimant@free.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox