digitalmars.D - Setting errno?
- Nick (4/4) Aug 15 2004 Is there any simple way to set the unix error value errno to zero? D imp...
- Arcane Jill (6/10) Aug 15 2004 I don't know the answer to this, but in any case, I'm not sure it's a pr...
- Nick (18/22) Aug 15 2004 I agree with this, but my use for errno is strictly for interfacing with...
- Nick (3/6) Aug 15 2004 Nevermind, I settled for just writing it in C myself.
- Walter (6/12) Aug 15 2004 implements
- Nick (5/7) Aug 15 2004 Yep. But I was sort of hoping you would put it in phobos like you did wi...
- Walter (4/12) Aug 15 2004 time.
- Nick (3/4) Aug 16 2004 Thanks a bunch then ;-)
- Regan Heath (6/22) Aug 16 2004 What about windows? errno exists on windows too.
- Walter (6/8) Aug 16 2004 errno really only exists in the windows C compiler runtime libraries as ...
- Martin M. Pedersen (19/24) Aug 17 2004 API.
- Matthew (3/25) Aug 17 2004 I agree.
- Martin M. Pedersen (7/8) Aug 18 2004 that's not correct.
Is there any simple way to set the unix error value errno to zero? D implements getErrno(), but it seems like library functions never reset errno unless a new error occurs. Nick
Aug 15 2004
In article <cfns9k$m9f$1 digitaldaemon.com>, Nick says...Is there any simple way to set the unix error value errno to zero? D implements getErrno(), but it seems like library functions never reset errno unless a new error occurs. NickI don't know the answer to this, but in any case, I'm not sure it's a practice we should be encouraging. The manual section "Error Handling in D" at http://www.digitalmars.com/d/errors.html explains why I think using errno is not a good idea. Arcane Jill
Aug 15 2004
In article <cfntcf$mq7$1 digitaldaemon.com>, Arcane Jill says...I don't know the answer to this, but in any case, I'm not sure it's a practice we should be encouraging. The manual section "Error Handling in D" at http://www.digitalmars.com/d/errors.html explains why I think using errno is not a good idea.I agree with this, but my use for errno is strictly for interfacing with C library functions, not for writing new code using this method of error reporting. I plan to encapsulate the errno entirely inside a class, making the internal workings invisible to the user. You can then write wrapper functions like this // Sets errno on failure extern(C) { char *some_func(int); } char[] someWrapper(int a) { char *p = some_func(a); if( Errno.error() ) throw new MyException(Errno.msg()); // Errno.msg() also 'clears' the error return std.string.toString(p); } The last part, where msg() clears the error, is hard to do if you can't change errno. Nick
Aug 15 2004
In article <cfns9k$m9f$1 digitaldaemon.com>, Nick says...Is there any simple way to set the unix error value errno to zero? D implements getErrno(), but it seems like library functions never reset errno unless a new error occurs.Nevermind, I settled for just writing it in C myself. Nick
Aug 15 2004
"Nick" <Nick_member pathlink.com> wrote in message news:cfo8u7$u1i$1 digitaldaemon.com...In article <cfns9k$m9f$1 digitaldaemon.com>, Nick says...implementsIs there any simple way to set the unix error value errno to zero? Da newgetErrno(), but it seems like library functions never reset errno unlessYou kind of have to write setErrno() in C, because errno is typically defined as a macro in <errno.h>. This is why getErrno() is written in C.error occurs.Nevermind, I settled for just writing it in C myself.
Aug 15 2004
In article <cfoao7$v10$1 digitaldaemon.com>, Walter says...You kind of have to write setErrno() in C, because errno is typically defined as a macro in <errno.h>. This is why getErrno() is written in C.Yep. But I was sort of hoping you would put it in phobos like you did with getErrno() so I wouldn't have to drag along the extra object file all the time. But it's really no big deal. Nick
Aug 15 2004
"Nick" <Nick_member pathlink.com> wrote in message news:cfocpc$10ac$1 digitaldaemon.com...In article <cfoao7$v10$1 digitaldaemon.com>, Walter says...time.You kind of have to write setErrno() in C, because errno is typically defined as a macro in <errno.h>. This is why getErrno() is written in C.Yep. But I was sort of hoping you would put it in phobos like you did with getErrno() so I wouldn't have to drag along the extra object file all theBut it's really no big deal.I'll add it to std.c.linux.linux
Aug 15 2004
In article <cfpkqs$1qpv$1 digitaldaemon.com>, Walter says...I'll add it to std.c.linux.linuxThanks a bunch then ;-) Nick
Aug 16 2004
On Sun, 15 Aug 2004 23:31:27 -0700, Walter <newshound digitalmars.com> wrote:"Nick" <Nick_member pathlink.com> wrote in message news:cfocpc$10ac$1 digitaldaemon.com...What about windows? errno exists on windows too. Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/In article <cfoao7$v10$1 digitaldaemon.com>, Walter says...time.You kind of have to write setErrno() in C, because errno is typically defined as a macro in <errno.h>. This is why getErrno() is written inC.Yep. But I was sort of hoping you would put it in phobos like you did with getErrno() so I wouldn't have to drag along the extra object file all theBut it's really no big deal.I'll add it to std.c.linux.linux
Aug 16 2004
"Regan Heath" <regan netwin.co.nz> wrote in message news:opscur54d55a2sq9 digitalmars.com...errno really only exists in the windows C compiler runtime libraries as an attempt to fake the unix errno behavior. It is not part of the Windows API. My intention is to skip the errno "middleman" on Win32 and go straight to the Win32 API, where GetLastError() does the trick.I'll add it to std.c.linux.linuxWhat about windows? errno exists on windows too.
Aug 16 2004
"Walter" <newshound digitalmars.com> skrev i en meddelelse news:cfs2ol$kr9$1 digitaldaemon.com...API.What about windows? errno exists on windows too.errno really only exists in the windows C compiler runtime libraries as an attempt to fake the unix errno behavior. It is not part of the WindowsMy intention is to skip the errno "middleman" on Win32 and go straight to the Win32 API, where GetLastError() does the trick.I think this is an unhealthy decision for several reasons: 1. I remember using C functions where the only way to determine if an error occurred or not, was to reset errno first, call the function, and then check if errno had been set. Without setErrno() such functions are rendered useless. 2. D might be used to implement libraries callable from C. setErrno() might be needed to communicate errors back. Without it an otherwise unneccesary layer of wrapping will be needed - something that I believe you yourself has strong negative feelings about. 3. In a multithreaded application, a thread-instance of errno is way better than SetLastError() and GetLastError(). 4. Leaving setErrno() out on Windows, you are placing an extra burden on the D developer that needs to maintain portable code. I hope this will help you reconsider. Regards, Martin
Aug 17 2004
"Martin M. Pedersen" <martin moeller-pedersen.dk> wrote in message news:cftl46$1cng$1 digitaldaemon.com..."Walter" <newshound digitalmars.com> skrev i en meddelelse news:cfs2ol$kr9$1 digitaldaemon.com...Are you saying the the Win32 error number is not thread-specific? If so, that's not correct.API.What about windows? errno exists on windows too.errno really only exists in the windows C compiler runtime libraries as an attempt to fake the unix errno behavior. It is not part of the WindowsMy intention is to skip the errno "middleman" on Win32 and go straight to the Win32 API, where GetLastError() does the trick.I think this is an unhealthy decision for several reasons: 1. I remember using C functions where the only way to determine if an error occurred or not, was to reset errno first, call the function, and then check if errno had been set. Without setErrno() such functions are rendered useless. 2. D might be used to implement libraries callable from C. setErrno() might be needed to communicate errors back. Without it an otherwise unneccesary layer of wrapping will be needed - something that I believe you yourself has strong negative feelings about. 3. In a multithreaded application, a thread-instance of errno is way better than SetLastError() and GetLastError().4. Leaving setErrno() out on Windows, you are placing an extra burden on the D developer that needs to maintain portable code. I hope this will help you reconsider.I agree.
Aug 17 2004
"Matthew" <admin.hat stlsoft.dot.org> skrev i en meddelelse news:cfu9io$1lpv$1 digitaldaemon.com...Are you saying the the Win32 error number is not thread-specific? If so,that's not correct. No, I have found that out by now. Well, three out of four is not bad :-) Regards, Martin
Aug 18 2004