Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
toplevel with pre-installed printers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-01-20 (16:49)
From: David Brown <caml-list2@d...>
Subject: Re: [Caml-list] toplevel with pre-installed printers
On Fri, Jan 20, 2006 at 01:24:03PM +1100, skaller wrote:

> You simply look at argv[0] which on some Unix systems
> is the full path name of the invoked executable.

Actually, argv[0] is almost never a full path.  It is the path used to
invoke the executable.  So, if the program is in the user's path, then it
will just be the filename, with no path information.

In order to find itself, a program has to search for argv[0] in $PATH.

If you don't believe me, try it:

   #include <stdio.h>
   main (int argc, char **argv)
     printf ("Program name: %s\n", argv[0]);

% gcc -o ~/bin/hello hello.c
% hello
Program name: hello