Brendan Doyle <Brendan.Doyle at Sun.COM> wrote:

> Thanks for the responses, but I believe that the argv/argc solution will
> not help  me,  I'm porting a library there is no main() or argv/argc.
>
> So I guess that basename(getexecname())  will work, but will it work on
> Linux?

No, but you could try to ask whether Linux glibc could add support for 
getexecname().


> Actually I'm not even sure that will work, program_invocation_short_name is
> global and set before main is called. So where in the library would I  call
> basename(getexecname()) to extract the string and update a global so that
> all functions in the library can use it?

getexecname() wil work.

You could add this:

#ifndef HAVE_GETEXECNAME
const char *
getexecname()
{
#ifdef  HAVE_PROGRAM_INVOCATION_NAME
        return (program_invocation_name);
#else
        return ("unknown");
#endif
}

Writing portable code requires you to know about portability issues.....

J?rg

-- 
 EMail:joerg at schily.isdn.cs.tu-berlin.de (home) J?rg Schilling D-13353 Berlin
       js at cs.tu-berlin.de                (uni)  
       joerg.schilling at fokus.fraunhofer.de (work) Blog: 
http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily

Reply via email to