[oclug]C/UNIX question
Phil Tanguay
ptanguay at magma.ca
Sat Oct 19 15:02:09 EDT 2002
On Sat, 19 Oct 2002, Bart Trojanowski wrote:
> Anyone know if there is a way for a library to find out what the
> process/executable name is that had called it?
>
> Ie, in a C app I can find out what the executable file name is by
> looking at argv[0]. I would like to do something similar from a
> library without needing to pass that info to the library from the
> application.
>
> I just needs this for debugging so unportable hacks are welcome. :)
How about you declare argc and argv as globals in your main app, like so ...
int argc;
char** argv;
int main(void)
{
}
and then in your lib you do :
extern int argc;
extern char** argv;
Then, you *should* be able to call argv/argc like you normally would do ?
Untested, but I don't see why this wouldn't work.
More information about the OCLUG
mailing list