[vox-tech] errno upon success (a real success)?

Micah J. Cowan vox-tech@lists.lugod.org
Thu, 10 Oct 2002 08:45:06 -0700


On Wed, Oct 09, 2002 at 08:28:14PM -0700, Peter Jay Salzman wrote:
> begin Micah J. Cowan <micah@cowan.name> 
> > On Wed, Oct 09, 2002 at 03:15:46PM -0700, Peter Jay Salzman wrote:
> > > does anyone know of an example where errno is set upon success that may
> > > not be as much of a stretch as taking the square root of infinity?
> > 
> > I'm pretty sure there are no such cases in C proper; dunno about
> > POSIX.
>  
> oi, i should know this by now.  sorry to have to ask, but what exactly
> is the difference between C proper and POSIX?  and where does ISO and
> ANSI fit in?

Well, the C language is defined in ISO/IEC 9899, whereas POSIX is
defined in IEEE 1003. I believe the POSIX standard is a collaborative
effort between IEEE, ISO and X/Open; but this may no longer be the
case (otherwise, it'd probably still be published as an ISO standard
rather than as an IEEE standard). I don't have my draft copy of POSIX
where I'm at now, so I'm not sure.

Standard C is often referred to as ISO C and sometimes (rather
imprecisely) as ANSI C. The latter reference is because C was
standardized by ANSI in 1989, and the exact same standard was accepted
by ISO as an International Standard in 1990. Currently, C is an ANSI
standard only *because* it is an ISO standard (and ANSI is a member of
ISO). So, "ISO C" is more accurate than "ANSI C".

POSIX defines scads of things. Some of them have pretty much nothing
to do with C; but a portion of it defines a set of header files and
extensions to the C programming language. Things like dirent.h, and
the open(), close(), read() and write() system calls (actually, *all*
standardized system calls) are from POSIX, not ISO C. Which is why none
of these are topical in comp.lang.c - that's what comp.unix.programmer
is for.

FWIW, ISO C doesn't even specify that, e.g., fopen() sets errno when a
file can't be open. IIRC, POSIX mandates that it does.

Another interesting difference: ISO C does not specify the size of a
"byte": only that it must be at *least* 8 bits (it could be
more). There are certain older systems which have non-octet bytes, and
also various modern CPUs which are used in embedded
applications. POSIX mandates that a byte is an octet.

HTH,
Micah