Thread View: comp.os.os2.programmer
3 messages
3 total messages
Started by Gerry Lachac
Thu, 20 Sep 1990 18:50
C6.00 and errno
Author: Gerry Lachac
Date: Thu, 20 Sep 1990 18:50
Date: Thu, 20 Sep 1990 18:50
19 lines
1127 bytes
1127 bytes
I've started converting a large amount of MSC 5.1 code to 6.0, and ran into a wall. My code sets errno to private values (retubned by a custom driver). In 5.1 this was no problem since errno was just an extern int. In 6.0 (I assume to facilitate threads) errno is defined as a function. I cannot find anything in the documentation that lets me set the errno value. The errno.h header file claims errno is set by "system functions". Does anyone know how to set errno in C6.0? -- uunet!dialogic!gerry | "Even a dead plant turns | Dialogic Corporation OR | over a new leaf | 300 Littleton Rd gerry@dialogic.UUCP | when the wind blows." | Parsippany, NJ 07054 | | (201)334-8450
Re: C6.00 and errno
Author: Jack Hudler
Date: Sat, 22 Sep 1990 07:33
Date: Sat, 22 Sep 1990 07:33
30 lines
1214 bytes
1214 bytes
> >The errno.h header file claims errno is set by "system functions". >Does anyone know how to set errno in C6.0? > Yes, you are correct about the thread influence on errno. Setting errno is pretty no-standard as your finding out, perhaps a better way might be to add your own error handling system. Such as; .. n = read(fd,&i,2); if (n<0) SetOurError(errno); // to trap system errors .. SetOutError(some_error_number); // and to generate your own. .. or; (if your a fan of Global Variables) .. n = read(fd,&i,2); if (n<0) ErrorCode=errno; // to trap system errors .. ErrorCode=some_error_number; // and to generate your own. .. -- Jack Computer Support Corporation Dallas,Texas Hudler Internet: jack@cscdec.cs.com
Re: C6.00 and errno
Author: Mark Towfiq
Date: Mon, 24 Sep 1990 18:51
Date: Mon, 24 Sep 1990 18:51
44 lines
2439 bytes
2439 bytes
In article <1#19@dialogic.UUCP> gerry@dialogic.UUCP (Gerry Lachac) writes: My code sets errno to private values (retubned by a custom driver). In 5.1 this was no problem since errno was just an extern int. In 6.0 (I assume to facilitate threads) errno is defined as a function. I cannot find anything in the documentation that lets me set the errno value. The errno.h header file claims errno is set by "system functions". Does anyone know how to set errno in C6.0? Several things to think of here -- a) Are you sure you want to use errno? Are you returning errors which make sense to the perror() routine, such as "File not found", "Permission denied", etc.? If not, maybe you should use your own global variable. This is especially necessary if you ever decide to write your own DLL, as it will no longer have access to the same errno as your application (I found this out the HARD way). b) If you still really want to use errno, just don't declare it yourself anywhere -- use stdlib.h, stddef.h and errno.h to set this def for you. Then you can just use errno as before, like: if (errno == EINTR) errno = 0; Because errno is actually defined as a macro: #define errno *(_errno()) And _errno() is a function which just returns the address of the errno variable. Note that this is just true when you are using the DLL side of things, and it is in fact the only way to set global variables inside a DLL, as the only interface to a DLL is through its stub calls, which are just functions. Hope this helps, Mark -- Mark Towfigh, Racal InterLan, Inc. towfiq@interlan.Interlan.COM W: (508) 263-9929 H: (617) 488-2818 uunet!interlan!towfiq "The Earth is but One Country, and Mankind its Citizens" -- Baha'u'llah
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads