std::abs(long)

Basile Starynkevitch basile@starynkevitch.net
Thu Mar 27 10:58:44 GMT 2025


On Thu, 2025-03-27 at 10:49 +0000, Jonathan Wakely via Gcc-help wrote:
> On Thu, 27 Mar 2025 at 10:48, Tom Kacvinsky via Gcc-help
> <gcc-help@gcc.gnu.org> wrote:
> > 
> > On Thu, Mar 27, 2025 at 6:28 AM Tom Kacvinsky <tkacvins@gmail.com> wrote:
> > 
> > > Hi,
> > > 
> > > I have a shared library that was built without linking to libstd++.so.6.
> > > The mangled named
> > > is _Z3St3absl.  But I can't it resolved in the libraries I link against.
> > > Where does this symbol originate?
> > > 
> > 
> > Answering my own question - it's defined as a builtin.
> 
> I don't think so, it's define in <bits/std_abs.h> like so:
> 
> #ifndef __CORRECT_ISO_CPP_STDLIB_H_PROTO
>   inline long
>   abs(long __i) { return __builtin_labs(__i); }
> #endif
> 
> So it's either provided by your C library (which is the case for
> Solaris, IIRC) or it's an inline function which should be define in
> every object file that uses it.

On Linux computers with GCC you should use the --demangle option to GNU nm or
programmatically the  <cxxabi.h> header with its abi::__cxa_demangle function
as documented on
https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html

For a concrete example see the RefPerSys GPL project in my signature (it should
become an inference engine).

Regards

    

-- 
Basile STARYNKEVITCH                            <basile@starynkevitch.net>
8 rue de la Faïencerie                       http://starynkevitch.net/Basile/  
92340 Bourg-la-Reine                         https://github.com/bstarynk
France                                https://github.com/RefPerSys/RefPerSys


More information about the Gcc-help mailing list