tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Adding <alloca.h> ?



Le jeu. 13 mai 2021 à 01:04, Joerg Sonnenberger <joerg%bec.de@localhost> a écrit :
>
> On Wed, May 12, 2021 at 08:32:20PM +0200, Jaromír Doleček wrote:
> > Le mer. 12 mai 2021 à 13:50, Joerg Sonnenberger <joerg%bec.de@localhost> a écrit :
> > >
> > > On Wed, May 12, 2021 at 08:38:39AM +0200, Jaromír Doleček wrote:
> > > > would it be a bad thing to add a compatibility <alloca.h> which would
> > > > use the builtin alloca() instead of the libc one when available?
> > > >
> > > > e.g. MySQL 8.0.* seems to rely on this.
> > >
> > > We provide it in stdlib.h as long as a standard mode is not set.
> > > I don't see the point of adding alloca.h.
> >
> > We don't provide the builtin in stdlib.h.
>
> Yes, we do.

No we don't, unless you are using PCC :D

The block in <stdlib.h> only provides an alloca(3) prototype, and only
if the compiler already #defines alloca as __builtin_alloca.

While this works for gcc in some -std modes (e.g. gnu++14), it does
not in others (c++14, c++11).

On the contrary, Linux <alloca.h> explicitely #undefs alloca(), then
#define alloca() as __builtin_alloca(), so it always works, regardless
which -std.

Jaromir


Home | Main Index | Thread Index | Old Index