Strings as function names (again)
Garry Garrett
garry at ceco.ceco.com
Sun Feb 24 02:59:00 AEST 1991
In article <8431 at exodus.Eng.Sun.COM>, limes at ouroborous.Eng.Sun.COM (Greg Limes) writes:
> In article <wolfram.666449950 at akela>, wolfram at akela.informatik.rwth-aachen.de (Wolfram Roesler) writes:
> |> >>One is that you have to tell it a path to the executable file, and
> |> >>that is not in general available for the currently-executing process.
> |>
> |> >Sure? How about argv[0] ?
>
[...]
> *
> * PORTABILITY
> * This was developed on a Sun3 running SunOS 4.0, but I think I
> * at least made the algorithm portable. You may need to mess
> * with include files and such. Symbolic link searching is turned
> * on if your errno.h supplies ELOOP, and off otherwise; I assume
> * that all systems with symlinks have a readlink() call.
> *
[...]
Your solution is interesting, but I think that here is where you
miss the point. C runs on many many many operating systems and platforms.
I have no doubt that your code will run on a sun, or most unix systems. On
the other hand, I doubt that it will run on a PC (MS-Dos), or a Mac or an
Amiaga, or a prime, or a machine running the OS-9 operating system...
The answer is, NO - there is no STANDARD way of knowing the name of
the currently exicuting file. On many systems, argv[0] does contain the
name of the currently exicuting file, often times with the full pathname.
If your C compiler doesn't, send the author hate mail until the next version
does, then maybe it will become a de-facto standard. In some cases, this is
not possible because of the way that the operating system works. In otherwords,
this information is not available from the operating system, so your compiler
could not possible give you this information. If that's the case then you
are stuck. :-(
More information about the Comp.lang.c
mailing list