🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #1532

Re: C6.00 and errno

#1532
From: Mark Towfiq
Date: Mon, 24 Sep 1990 18:51
44 lines
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
Technical Details
Message-ID: <TOWFIQ.90Sep24145112@lcxserver.InterLan.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!samsung!interlan.InterLan.COM!interlan.interlan.com!towfiq
References: <1#19@dialogic.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!samsung!interlan.InterLan.COM!interlan.interlan.com!towfiq
From: towfiq@interlan.Interlan.COM (Mark Towfiq)
Newsgroups: comp.os.os2.programmer
Subject: Re: C6.00 and errno
Message-ID: <TOWFIQ.90Sep24145112@lcxserver.InterLan.COM>
Date: 24 Sep 90 18:51:12 GMT
References: <1#19@dialogic.UUCP>
Sender: news@interlan.Interlan.COM (No News is BAD News)
Organization: Racal InterLan, Inc., Boxborough, MA (1-800-LAN-TALK)
Lines: 44
In-Reply-To: gerry@dialogic.UUCP's message of 20 Sep 90 18:50:15 GMT
Nntp-Posting-Host: lcxserver.interlan.com