James Carlson wrote:
> Brendan Doyle SMI European Software Centre writes:
>> Well for one 'program_invocation_short_name' I know there are 
>> alternatives to
>> this, but I'm trying to avoid solaris specific #defines in the source.
> 
> Filing an RFE is probably the better alternative for something simple
> like that.
> 
> Of course, if this were my code, I'd do something like this instead:
> 
>       if ((cp = strrchr(argv[0], '/')) == NULL)
>               cp = argv[0];
>       else
>               cp++;
> 
> That should work on any system, and doesn't require reaching for a
> non-portable construct like 'program_invocation_short_name'.
> 
> As for the #defines issue, well, writing portable code can sometimes
> be hard, but I think it beats trying to coerce all systems to look the
> same.

In this particular case, I think basename(getexecname()) is probably 
preferable for OpenSolaris, and BSD has getprogname().

argv[0] behaviour varies from OS to OS; on some it's left NULL or blank.

Cheers,
-- 
Shawn Walker

Reply via email to