What is the purpose of hiding the `aligned_alloc` declaration like this in `core.stdc.stdlib`?
```d
 29    version (CRuntime_Glibc)
 30        version = AlignedAllocSupported;
 31    else version (CRuntime_Newlib)
 32        version = AlignedAllocSupported;
 33    else {}
...
184    /// since C11
185    version (AlignedAllocSupported)
186    {
187        void* aligned_alloc(size_t alignment, size_t size);
188    }
```
—— my system is definitely not `CRuntime_Glibc` or `CRuntime_Newlib` as shown by the output of the following example:
```d
import core.stdc.stdlib : malloc, free, aligned_alloc;

// extern(C) void* aligned_alloc(size_t alignment, size_t size); // uncomment to compile

import core.stdc.stdio:printf;
void main()
{
    int* p1;
    p1 = cast(int*)malloc(10* p1.sizeof);
    printf("default-aligned addr:   %p\n", cast(void*)p1);
    free(p1);

    int* p2;
    p2 = cast(int*)aligned_alloc(1024, 1024* p2.sizeof);
    printf("1024-byte aligned addr: %p\n", cast(void*)p2);
    free(p2);
}
```

—— output:
```
aligned.d(1): Error: module `core.stdc.stdlib` import `aligned_alloc` not found
import core.stdc.stdlib : aligned_alloc;
       ^
```

—— but it compiles fine when compiled with `-version=AlignedAllocSupported` or if I declare the `aligned_alloc` myself. Here is the output of the above example with the `-version` flag set on my system:
```
default-aligned addr:   0x600002d08050
1024-byte aligned addr: 0x7fafb380e800
```

Reply via email to