[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: error.c has an unnecessary dependency on "program_name"
From: |
Bruno Haible |
Subject: |
Re: error.c has an unnecessary dependency on "program_name" |
Date: |
Sun, 7 Nov 2010 21:40:55 +0100 |
User-agent: |
KMail/1.9.9 |
Bruce Korb wrote:
> error.c has an unnecessary dependency on "program_name"
No, it is not an "unnecessary" dependency. There is no portable way for code
in a module to determine the name of the current program. Programs that use the
'error' module must define the program_name variable and assign it a value.
> It is fairly easy to fix, just make the definition weak
> and check for a NULL value before using it. OK to push?
>
> index ed9dba0..65f2d9d 100644
> --- a/lib/error.c
> +++ b/lib/error.c
> @@ -106,7 +106,7 @@ char *strerror_r ();
>
> /* The calling program should define program_name and set it to the
> name of the executing program. */
> -extern char *program_name;
> +char *program_name;
> ...
> + char const *p = program_name ? program_name : "unknown";
No, this is not OK, for two reasons:
1) It will cause a link error for all programs that define the 'program_name'
variable, on all non-ELF platforms (mainly MacOS X and Woe32).
2) Substituting "unknown" instead of a real program name will not help the
end user.
Bruno
- error.c has an unnecessary dependency on "program_name", Bruce Korb, 2010/11/07
- Re: error.c has an unnecessary dependency on "program_name",
Bruno Haible <=
- Re: libposix stuff, Bruce Korb, 2010/11/08
- Re: libposix stuff, Gary V. Vaughan, 2010/11/08
- Re: libposix stuff, Ralf Wildenhues, 2010/11/08
- Re: libposix stuff, Bruce Korb, 2010/11/08
- Re: libposix stuff, Eric Blake, 2010/11/08
- Re: libposix stuff, Bruce Korb, 2010/11/08
- Re: libposix stuff, Thien-Thi Nguyen, 2010/11/09