Question about _GLIBCXX_WEAK_DEFINITION macro

Jonathan Wakely
Tue Aug 11 07:25:33 GMT 2020

On Tue, 11 Aug 2020 at 04:09, 孙世龙 sunshilong <> wrote:
> 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?

On platforms using the ELF binary format it just works automatically,
because it's a property of ELF that symbols in the executable can
replace symbols of the same name in a library. This is called symbol
interposition. See for more

MacOS doesn't use ELF, so it needs another mechanism to make the
default definitions of operator new and operator delete replaceable.

> Just because of overloading? Can I think in this way?

No. It's not overloading if you have two functions with the same parameter list.

More information about the Libstdc++ mailing list