Re: using long long and printf("%m") in debian
On Sun, Aug 20, 2006 at 03:59:17PM +0300, Lars Wirzenius wrote:
[...]
> fprintf(stderr, "Could not read file: %s: %s\n", filename,
> strerror(errno));
>
> Please consider the above a minimal requirement for an error message: it
> reports the operation that was attempted (reading a file), the target of
> the operation (the filename), and the error message.
>
> perror is, on the whole, useful only in throwaway programs, or programs
> whose users like guessing.
Bullshit. The above could also have been done as
sprintf(buf, "Could not read file %s", filename)
perror(buf);
or, perhaps (depending on what the file actually was):
perror("Could not read configuration file");
It's all a question of what exactly you specify as the string in the
call to perror. Of course using __FUNCTION__ is hardly ever useful to
the end-user, at least if you use it on its own. If properly used,
however, there's nothing wrong with perror.
--
Fun will now commence
-- Seven Of Nine, "Ashes to Ashes", stardate 53679.4
Reply to: