|
|
Standard return defs?
I notice in my stdlib.h:
#define EXIT_FAILURE 1 /* Failing exit status. */
#define EXIT_SUCCESS 0 /* Successful exit status. */
Are these definitions dictated by the standard? I've seen them used often
in
this group so I assume they are.
If so, are there any other standard defined return values that I could use
in functions?
i.e RETURN_SUCCESS, ERR_NO_MEM, ERR_FILE_NOT_OPENED, ERR_BAD_PROGRAMMER, or
such?
Stephen
|
|
0
|
|
|
|
Reply
|
alone1 (1)
|
8/11/2004 10:46:25 PM |
|
Stephen Mayes wrote:
>
> I notice in my stdlib.h:
>
> #define EXIT_FAILURE 1 /* Failing exit status. */
> #define EXIT_SUCCESS 0 /* Successful exit status. */
>
> Are these definitions dictated by the standard?
Yes. The values are implementation defined.
> I've seen them used often in this group so I assume they are.
>
> If so, are there any other standard defined return values
> that I could use in functions?
No.
--
pete
|
|
0
|
|
|
|
Reply
|
pfiland (6613)
|
8/11/2004 11:10:02 PM
|
|
Stephen Mayes wrote on 12/08/04 :
> I notice in my stdlib.h:
>
> #define EXIT_FAILURE 1 /* Failing exit status. */
> #define EXIT_SUCCESS 0 /* Successful exit status. */
>
> Are these definitions dictated by the standard? I've seen them used often
> in
> this group so I assume they are.
Yes. There are used with exit() and the return from main().
> If so, are there any other standard defined return values that I could use
> in functions?
Not that I am aware of. Of course you have the errno values (Exxx) .
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
"C is a sharp tool"
|
|
0
|
|
|
|
Reply
|
emdel (952)
|
8/12/2004 12:19:14 AM
|
|
"Stephen Mayes" <alone@last.com> writes:
> I notice in my stdlib.h:
>
> #define EXIT_FAILURE 1 /* Failing exit status. */
> #define EXIT_SUCCESS 0 /* Successful exit status. */
>
> Are these definitions dictated by the standard? I've seen them used
> often in this group so I assume they are.
As pete pointed out, EXIT_FAILURE and EXIT_SUCCESS are standard, but
their values are implementation-defined. The value 0 also denotes a
successful exit status; it may or may not be equal to EXIT_SUCCESS.
> If so, are there any other standard defined return values that I
> could use in functions? i.e RETURN_SUCCESS, ERR_NO_MEM,
> ERR_FILE_NOT_OPENED, ERR_BAD_PROGRAMMER, or such?
EXIT_SUCCESS and EXIT_FAILURE are intended to be passed to the exit()
function or (nearly equivalently) used as the return value from
main(). They're not intended to be returned from arbitrary functions.
You can certainly use them that way if you want to, but it's likely to
cause confusion.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
|
|
0
|
|
|
|
Reply
|
kst-u (21469)
|
8/12/2004 12:49:32 AM
|
|
Stephen Mayes <alone@last.com> scribbled the following:
> I notice in my stdlib.h:
> #define EXIT_FAILURE 1 /* Failing exit status. */
> #define EXIT_SUCCESS 0 /* Successful exit status. */
> Are these definitions dictated by the standard? I've seen them used often
> in
> this group so I assume they are.
These macros are standard but their expansions aren't. You can't depend
on EXIT_SUCCESS being 0, and you certainly can't depend on EXIT_FAILURE
being 1. However, 0 will always work as a return value meaning
successful exit.
> If so, are there any other standard defined return values that I could use
> in functions?
> i.e RETURN_SUCCESS, ERR_NO_MEM, ERR_FILE_NOT_OPENED, ERR_BAD_PROGRAMMER, or
> such?
Not that I know of.
--
/-- Joona Palaste (palaste@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"To know me IS to love me."
- JIPsoft
|
|
0
|
|
|
|
Reply
|
palaste (2323)
|
8/12/2004 8:04:49 AM
|
|
|
4 Replies
32 Views
(page loaded in 0.106 seconds)
|
|
|
|
|
|
|
|
|