Date: Sun, 24 May 1998 20:21:51 +0300 (IDT) From: Eli Zaretskii To: DJ Delorie cc: djgpp-workers AT delorie DOT com Subject: errno and ANSI compliance Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk ANSI requires that errno be zero at program startup. This simple change makes us comply: *** src/libc/crt0/crt1.c~0 Mon Dec 29 22:09:42 1997 --- src/libc/crt0/crt1.c Sat May 23 17:02:52 1998 *************** *** 5,10 **** --- 5,11 ---- #include #include #include + #include #include #include #include *************** __crt1_startup(void) *** 167,172 **** --- 168,174 ---- _npxsetup(pn); _crt0_init_mcount(); __main(); + errno = 0; /* ANSI says errno should be zero at program startup */ exit(main(__crt0_argc, __crt0_argv, environ)); } *** src/docs/kb/wc202.t~9 Sat Apr 18 17:09:08 1998 --- src/docs/kb/wc202.txi Sat May 23 17:34:56 1998 *************** *** 362,364 **** --- 362,370 ---- @code{system} is now compliant with ANSI C Standard when its argument is a NULL pointer. @findex system + + Previously, at program startup @code{errno} would retain whatever value + it was assigned by the DJGPP startup code. ANSI C Standard requires + @code{errno} to be zero at the beginning of @code{main}, so it is now + reset to zero before calling @code{main}. + @vindex errno