incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STDCXX-244) [HP aCC] no abs() in <stdlib.h> when <math.h> is #included first
Date Thu, 29 Jun 2006 23:29:30 GMT
    [ http://issues.apache.org/jira/browse/STDCXX-244?page=comments#action_12418536 ] 

Martin Sebor commented on STDCXX-244:
-------------------------------------

Here's what HP had to say about this when it was first discussed:

****Created By: sebor @ Sep 21, 2000 04:04:11 PM****
Subject: is <stdlib.h> supposed to define abs() in +nostl mode?
Date: Thu, 21 Sep 2000 13:30:04 -0600
From: Martin Sebor <sebor@roguewave.com>
Organization: Rogue Wave Software, Inc.
To: HP aCC bug list <acxx-beta@cup.hp.com>

I'm trying to get our C++ libc headers to work and I'm running into a minor snag -- is the
error below intended behavior?

$ cat t.cpp
#include <math.h>
#include <stdlib.h>

int main ()
{
   return abs (0);
}

$ aCC +nostl -I/usr/include t.cpp
Error 328: "t.cpp", line 6 # Function 'abs' has not been defined yet;
cannot
   call.
       return abs (0);
              ^^^    
/usr/include/stdlib.h only seems to define abs() if <math.h> hasn't been
#included yet but /usr/include/math.h doesn't define it:

$ cat -n /usr/include/stdlib.h | tail -n +65 | head -7
   65  #    ifndef __cplusplus
   66         extern int abs(int);
   67  #    else
   68  #      ifndef _MATH_INCLUDED
   69          inline int abs(int d) { return (d>0)?d:-d; }
   70  #      endif /* _MATH_INCLUDED */
   71  #    endif

$ cat -n /usr/include/math.h | tail -11
  403  #if defined(__cplusplus) && (__cplusplus < 199707)
  404     inline int sqr(int x) {return(x*x);}
  405     inline double sqr(double x) {return(x*x);}
  406  #  ifndef _STDLIB_INCLUDED
  407       inline int abs(int d) { return (d>0)?d:-d; }
  408  #  endif /* _STDLIB_INCLUDED */
  409     inline double abs(double d) { return fabs(d); }
  410  #endif
  411
  412
  413  #endif /* _MATH_INCLUDED */

It seems to me that the guard in <stdlib.h> should take (__cplusplus <
199707) into consideration.

Thanks
Martin
****Modified By: sebor @ Sep 21, 2000 06:57:36 PM****
Subject: Re: is <stdlib.h> supposed to define abs() in +nostl mode?
Date: Thu, 21 Sep 2000 16:02:21 -0700 (PDT)
From: Dennis Handly <dhandly@cup.hp.com>
To: acxx-beta@cup.hp.com, sebor@roguewave.com

>is the error below intended behavior?

Yes, you can't just use -I/usr/include.  You must use the two other aC++ wrappers around the
headers.

In particular it is in /opt/aCC/include/cstdlib and cmath.


  403  #if defined(__cplusplus) && (__cplusplus < 199707)

>It seems to me that the guard in <stdlib.h> should take (__cplusplus <
>199707) into consideration.
Martin

You mean __cplusplus >= 199707.  It was decided to rip that out of
the system headers and put it in the aC++ specific ones.
****Modified By: sebor @ Sep 21, 2000 06:58:42 PM****
Subject: Re: is <stdlib.h> supposed to define abs() in +nostl mode?
Date: Thu, 21 Sep 2000 17:54:16 -0700 (PDT)
From: Dennis Handly <dhandly@cup.hp.com>
To: sebor@roguewave.com
CC: acxx-beta@cup.hp.com

>It's unexpected that if I #include <stdlib.h> alone ::abs() is declared
>but if I #include <math.h> first it disappears. Reversing the order also
>makes a difference which should never be.

Except you can't use the files in /usr/include for C++ without something extra.  And unfortunately
we are stuck with it.

> [HP aCC] no abs() in <stdlib.h> when <math.h> is #included first
> ----------------------------------------------------------------
>
>          Key: STDCXX-244
>          URL: http://issues.apache.org/jira/browse/STDCXX-244
>      Project: C++ Standard Library
>         Type: Bug

>   Components: External
>  Environment: HP aCC all versions going as far back as 3.00 on HP-UX as old as 11.00
>     Reporter: Martin Sebor

>
> $ cat t.cpp && aCC -AA +nostl -I/usr/include t.cpp
> #include <math.h>
> #include <stdlib.h>
> int main ()
> {
>    return abs (0);
> }
> Error 328: "t.cpp", line 6 # Function 'abs' has not been defined yet; cannot call.
>        return abs (0);
>               ^^^

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message