delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/11/04/17:24:30

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
From: Kbwms AT aol DOT com
Message-ID: <5a.240b82cc.2cd980ed@aol.com>
Date: Tue, 4 Nov 2003 17:23:41 EST
Subject: Re: C99 Functions Under Development and Checkout
To: djgpp-workers AT delorie DOT com
MIME-Version: 1.0
X-Mailer: 8.0 for Windows sub 6021
Reply-To: djgpp-workers AT delorie DOT com

--part1_5a.240b82cc.2cd980ed_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

Rich Dawe:

That pretty much covers my thinking to date on the matter.  Keep in mind that 
math_errhandling can be either MATH_ERRNO or MATH_ERREXCEPT
or _both_ and remains constant for the duration of the program.  This seems 
to imply that user must be provided some ability to set math_errhandling at 
startup.  On the other hand, if some miscreant user decides to define an 
identifier with the name math_errhandling, all bets are off (the behavior is 
undefined).

What this means is that a user must be given the opportunity to set 
math_errhandling once only.

It is preferable that math_errhandling be an inviolate global variable rather 
than be available only through function linkage.


Thanks for your thoughtful response.


KB Williams


In a message dated 11/4/2003 3:02:12 PM Eastern Standard Time, 
rich AT phekda DOT freeserve DOT co DOT uk writes:

> As I interpret it:
> 
> An "identifier with external linkage" in this case would be a global 
> variable.
> 
> I guess the two options you have are:
> 
> (1) In a new source module define a library internal function to return the
> error-handling status. E.g.:
> 
> #include <math.h>
> 
> static const int __math_errhandling = MATH_ERRNO|MATH_ERREXCEPT;
> 
> int __get_math_errhandling (void)
> {
>  return __math_errhandling;
> }
> 
> Then in <math.h> define the macro to call the function:
> 
> extern int __get_math_errhandling(void);
> #define math_errhandling (__get_math_errhandling());
> 
> (2) Just define the macro:
> 
> #define math_errhandling (MATH_ERRNO|MATH_ERREXCEPT)
> 
> I prefer (1), because it keeps the details out of <math.h>.
> 


--part1_5a.240b82cc.2cd980ed_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<HTML><FONT FACE=3Darial,helvetica><FONT  SIZE=3D3 FAMILY=3D"SERIF" FACE=3D"=
Georgia" LANG=3D"0">Rich Dawe:<BR>
<BR>
That pretty much covers my thinking to date on the matter.&nbsp; Keep in min=
d that math_errhandling can be either </FONT><FONT  COLOR=3D"#000000" style=
=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2 FAMILY=3D"SANSSERIF" FACE=3D"Arial"=20=
LANG=3D"0">MATH_ERRNO </FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-CO=
LOR: #ffffff" SIZE=3D3 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0">or</FONT=
><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2 FAMIL=
Y=3D"SANSSERIF" FACE=3D"Arial" LANG=3D"0"> MATH_ERREXCEPT</FONT><FONT  COLOR=
=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D3 FAMILY=3D"SERIF" F=
ACE=3D"Georgia" LANG=3D"0"><BR>
or _both_ and remains constant for the duration of the program.&nbsp; This s=
eems to imply that user must be provided some ability to set math_errhandlin=
g at startup.&nbsp; On the other hand, if some miscreant user decides to def=
ine an identifier with the name math_errhandling, all bets are off (the beha=
vior is undefined).<BR>
<BR>
What this means is that a user must be given the opportunity to set math_err=
handling once only.<BR>
<BR>
It is preferable that math_errhandling be an inviolate global variable rathe=
r than be available only through function linkage.<BR>
<BR>
<BR>
Thanks for your thoughtful response.<BR>
<BR>
<BR>
KB Williams<BR>
<BR>
<BR>
In a message dated 11/4/2003 3:02:12 PM Eastern Standard Time, rich AT phekda DOT f=
reeserve.co.uk writes:<BR>
<BR>
<BLOCKQUOTE TYPE=3DCITE style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT=
: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"></FONT><FONT  COLOR=3D"#000000"=
 style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2 FAMILY=3D"SANSSERIF" FACE=3D"A=
rial" LANG=3D"0">As I interpret it:<BR>
<BR>
An "identifier with external linkage" in this case would be a global variabl=
e.<BR>
<BR>
I guess the two options you have are:<BR>
<BR>
(1) In a new source module define a library internal function to return the<=
BR>
error-handling status. E.g.:<BR>
<BR>
#include &lt;math.h&gt;<BR>
<BR>
static const int __math_errhandling =3D MATH_ERRNO|MATH_ERREXCEPT;<BR>
<BR>
int __get_math_errhandling (void)<BR>
{<BR>
 return __math_errhandling;<BR>
}<BR>
<BR>
Then in &lt;math.h&gt; define the macro to call the function:<BR>
<BR>
extern int __get_math_errhandling(void);<BR>
#define math_errhandling (__get_math_errhandling());<BR>
<BR>
(2) Just define the macro:<BR>
<BR>
#define math_errhandling (MATH_ERRNO|MATH_ERREXCEPT)<BR>
<BR>
I prefer (1), because it keeps the details out of &lt;math.h&gt;.<BR>
</BLOCKQUOTE><BR>
</FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D3=
 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><BR>
</FONT></HTML>
--part1_5a.240b82cc.2cd980ed_boundary--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019