Alloca without core.stdc.stdlib?

ARaspiK araspik at protonmail.com
Fri Jun 29 09:28:18 UTC 2018


On Friday, 29 June 2018 at 09:17:58 UTC, ARaspiK wrote:
> According to core.stdc.stdlib, alloca (on GDC) is a compiler 
> intrinsic.
> But I can't separate it from the rest of core.stdc.stdlib, for 
> a small druntime I'm making. Here's what it seems to be:
>
> version(GNU) extern(C) @system nothrow @nogc void* 
> alloca(size_t size) pure;
>
> Writing the declaration to a file, or even removing everything 
> else from core.stdc.stdio, isn't working. I cannot have any C 
> library stuff. How do I isolate it?

After a little more digging around, I found that you can import 
GCC's builtin functions (including __builtin_alloca) from 
gcc.builtins. I copied the file exactly, and GCC provided.

It seems that simply importing an empty module named gcc.builtins 
is enough to get GDC to pull everything. You can also simply 
import it from the default location.


More information about the D.gnu mailing list