Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: error_t proposal Date: Wed, 04 Sep 2019 15:20:06 -0700 Organization: None to speak of Lines: 36 Message-ID: References: <5d03868d-22f7-4c7f-9f9b-1e70d8d8e6f2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="808e9da1912e399f965b4512b95a962e"; logging-data="1407"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18swo5L1E433KKleLx9lOR2" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:m8FreSmNmEMjoG7+ZdhWWXak9V4= sha1:iZgvJE0K+plezF5xFWf2jk6diXk= Xref: csiph.com comp.lang.c:146001 Thiago Adams writes: > In my experience, most of the time I don't need to check > for specific errors. > > For instance, I rarely need to do this: > > if (error == specific_error) { > /*do something*/ > } > > in general I just check for general errors: > > if (error != error_success) { > /*do something*/ > } > > Some libraries uses 0 to say "no error" and others use > 1 or true do say "no error". [...] What libraries use 1 to denote "no error"? In my experience, error codes in C are almost always zero for success, non-zero for failure (with either the value or errno providing more information about the error). (My experience does have a UNIX/POSIX/Linux bias.) Some functions (not many in the standard library) might return 0 for "false" and 1 or non-zero for "true" (for example isdigit() et al), but for those functions "false" is not an error, just a piece of information. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */