473,698 Members | 2,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_OP ENED, ERR_BAD_PROGRAM MER, or
such?

Stephen
Nov 14 '05 #1
4 1725
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
Nov 14 '05 #2
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"

Nov 14 '05 #3
"Stephen Mayes" <al***@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_OP ENED, ERR_BAD_PROGRAM MER, 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_Keit h) ks***@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.
Nov 14 '05 #4
Stephen Mayes <al***@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_OP ENED, ERR_BAD_PROGRAM MER, or
such?


Not that I know of.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"To know me IS to love me."
- JIPsoft
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3595
by: Karl Irvin | last post by:
Can you loop through Query Defs and get the name of the tables/queries used in each query?
6
2394
by: RoSsIaCrIiLoIA | last post by:
Do you know how to write a self-checking program in standard C? Do I can think that if I write in a file.c static g="1234567"; in the file.exe (or file) there is in some place 1234567'\0''\0''\0''\0''\0''\0''\0'...'\0' This is my first attempt: /* file.c -> file.exe */ #include <stdio.h>
15
1622
by: Walter Dnes (delete the 'z' to get my real address | last post by:
A long time ago, in a place far away, there was an OS called DOS that had standard numeric return codes. Regardless of the programming language used, the same error return codes were supposed to be used. See http://www.felgall.com/doserr.htm for a larger list. It starts like so... # 1 Invalid Function Code # 2 File Not Found # 3 Path Not Found # 4 No Handles Available, Too Many Open Files # 5 Access Denied
2
1843
by: G Patel | last post by:
aan anyone tell me what a .defs and .s file extensions are in a C program (folder)? thanks a lot
14
2556
by: embeddedc | last post by:
Hi, Referring to C90, is there somewhere published a list of all parts of the standard where the behavior is not specified or implementation dependent? If not and I want to find all such parts I could search a pdf version of the standard for keywords such as "implementation dependent" to highlight the section. Can anybody suggest a complete list of such keywords to make sure I find all the relevant sections?
32
2030
by: r.z. | last post by:
class vector3 { public: union { float data; struct { float x, y, z; };
4
1667
by: dustin | last post by:
I've been hacking away on this PEP for a while, and there has been some related discussion on python-dev that went into the PEP: http://mail.python.org/pipermail/python-dev/2007-February/070921.html http://mail.python.org/pipermail/python-dev/2007-February/071155.html http://mail.python.org/pipermail/python-dev/2007-February/071181.html I'd love to have feedback on this PEP: - from a user's perspective (would you want to write...
2
1547
by: parag_paul | last post by:
Isnt is so that whenever the compiler reads an #def it will replace it with letter by letter on the place is see the macro, so what is the purpose of keeping #defs inside a structure, struct A{ #define A_list(e) (e)->list() }
270
9448
by: jacob navia | last post by:
In my "Happy Christmas" message, I proposed a function to read a file into a RAM buffer and return that buffer or NULL if the file doesn't exist or some other error is found. It is interesting to see that the answers to that message prove that programming exclusively in standard C is completely impossible even for a small and ridiculously simple program like the one I proposed. 1 I read the file contents in binary mode, what should...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9027
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.