This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: abs function question
On Tue, Jul 29, 2003 at 08:00:19AM +0200, Gabriel Dos Reis wrote:
> Nathan Myers <ncm-nospam@cantrip.org> writes:
>
> | On Tue, Jul 29, 2003 at 06:39:30AM +0200, Gabriel Dos Reis wrote:
> | > Steve Ellcey <sje@cup.hp.com> writes:
> | >
> | > | I am currently running into a problem with the function abs and the
> | > | header std_cstdlib.h.
> | >
> | > Huh!? How can an inline definition could possibly clash with a using
> | > declaration? Some piece of information is missing. Could tell us
> | > more about that inline declaration?
> |
> | I think he's saying that if __cplusplus is defined, no abs is declared
> | at all,
>
> How do you read that from
>
> The problem is that my system's stdlib.h header file is smart enough to
> not do an extern declaration for abs if it is in C++ mode and *instead
> does an inline declaration of the abs function*.
>
> ?
Selective garbling. If the original question doesn't make sense, try
small perterbations. An "inline declaration" doesn't mean anything.
Maybe the header assumes it *will* be defined inline, or maybe it
defines a macro if not in C++. Obviously we can't be sure without
more information. All we do know is that is doesn't work now.
It would be an unfortunate choice to use ::abs, generally, because in
C it's not going to be defined inline. In C there's generally a macro
abs() hiding it, which we have to #undef because it doesn't scope.
Leaving it undeclared in their header allows C++ to define both ::abs
(extern) inline and std::abs aliased to it, or vice versa.
Nathan Myers
ncm-nospam@cantrip.org