Luiz Fernando Capitulino wrote:
> I have a question about 'errno' which I'm postponing for some
> time: is it a bad pratice to set 'errno' by hand in libraries
> and even in ordinary programs?
>
> I mean, AFAIK 'errno' was created to store error codes from system
> calls, but it's widely used by several libraries. Sometimes is even
> helpful to set 'errno' in the program itself, something like:
>
> int get_foobar_info(char *value)
> {
> if (!value) {
> errno = EINVAL;
> return -1;
> }
>
> ...
>
> return 0;
> }
>
> Is it a bad pratice? Is there a 'limit' for 'errno' usage?
No; there's no reason you can't use errno for your own purposes.
Many library functions will set errno; even if they don't set it
explicitly, they can call libc (etc) function which can set it.
--
Glynn Clements <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming"
in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html