From: jojo AT sics DOT se (Jesper Eskilson) Subject: Re: setting errno 21 Jan 1999 07:46:49 -0800 Message-ID: <199901210814.JAA25920.cygnus.gnu-win32@brahma.sics.se> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To: > From: DJ Delorie > To: gnu-win32 AT cygnus DOT com > Subject: Re: setting errno > Date: den 20 januari 1999 01:01 > > Tim Taylor wrote: > > > > I'm porting a program that sets errno if an operation fails. However, in > > the B20.1 errno is a macro that dereferences the pointer returned by a > > function #define errno (*__errno()) > > > > What is the proper way to set errno in cygwin? > > The correct way is, always was, and always will be, like thus: > > #include > > errno = N; > > The ANSI spec requires it to be so. More specifically, the ANSI spec requires that errno be an lvalue, precisely to allow it to expand to a function returning a dereferenced pointer. And quite a lot of compilers (or rather, header files) define it that way. Unfortunately, it is not often clearly stated that this is the case (not every C programmer reads the ANSI standard that carefully), leading to serious confusion when someone tries to handle errno as if it was a variable. ------------------------------------------------- Jesper Eskilson mailto:jojo AT sics DOT se http://www.sics.se/~jojo - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".