Question about _GLIBCXX_WEAK_DEFINITION macro
孙世龙 sunshilong
sunshilong369@gmail.com
Tue Aug 11 03:09:06 GMT 2020
Thank you for your reply.
>> So, can I draw the conclusion that _GLIBCXX_WEAK_DEFINITION does not
>> any influence on other platforms(not include darwin)?
>Correct.
One more question arises, why the new operator/keyword could be
replaced by self-defined function even if there is no "__attribute__
((weak)))" on other platforms?
Just because of overloading? Can I think in this way?
For your convenience, here is some related code snippet:
_GLIBCXX_WEAK_DEFINITION void*
operator new[] (std::size_t sz, const std::nothrow_t&) noexcept {...}
_GLIBCXX_WEAK_DEFINITION void *
operator new (std::size_t sz) _GLIBCXX_THROW (std::bad_alloc){...}
Best Regards.
Sunshilong
On Fri, Aug 7, 2020 at 3:51 PM Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
> On Fri, 7 Aug 2020 at 02:50, 孙世龙 sunshilong via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
> >
> > On darwin, _GLIBCXX_WEAK_DEFINITION is equivalent to __attribute__ ((weak)).
> > (for details, see config/os/bsd/darwin/os_defines.h :
> > #define _GLIBCXX_WEAK_DEFINITION __attribute__ ((weak)))
> >
> > What confuses me is that there are no such similar definitions for
> > other platforms.
> > I only found such definitions for other platforms:
> >
> > // Certain function definitions that are meant to be overridable from
> > // user code are decorated with this macro. For some targets, this
> > // macro causes these definitions to be weak.
> > #ifndef _GLIBCXX_WEAK_DEFINITION
> > # define _GLIBCXX_WEAK_DEFINITION
> > #endif
> >
> > So, can I draw the conclusion that _GLIBCXX_WEAK_DEFINITION does not
> > any influence on other platforms(not include darwin)?
>
> Correct.
More information about the Libstdc++
mailing list