Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!purdue!ames!apple!motcsd!hpda!hpcuhb!hpcllla!hpclisp!hpclwjm!walter From: walter@hpclwjm.HP.COM (Walter Murray) Newsgroups: comp.sys.hp Subject: Re: Strange behaviour on HP9000/825 Message-ID: <1340063@hpclwjm.HP.COM> Date: 27 Jul 89 20:50:10 GMT References: <227@innovus.UUCP> Organization: Hewlett-Packard Calif. Language Lab Lines: 22 Several others have pointed out the problem of checking errno when no error condition has been indicated. Here are a few more interesting things to know about errno, which will be true in any ANSI-conforming compiler and library. 1. The value of errno is always zero at program startup. 2. The program itself may set errno to zero, but none of the standard library functions will ever do so. 3. Even though any particular library function may not be documented to use errno, it is possible that that function will set errno to a nonzero value, regardless of whether an error occurred. 4. For portability, it is better not to declare errno yourself. Just include and rely on the declaration there. On some systems, errno will be a macro, and if you try to declare it yourself as 'extern int', there'll be a problem. Walter Murray Hewlett-Packard ----------------------------------------------------------------------