May 21, 2018 Can I work out error: reinterpreting cast from const(ubyte)* to const(uint)* is not supported in CTFE? | ||||
---|---|---|---|---|
| ||||
I'm trying to do some hashing at compile time with xxhash algorithm but I get this error: ..\..\..\AppData\Local\dub\packages\xxhash-master\xxhash\src\xxhash.d(39,37): Error: reinterpreting cast from const(ubyte)* to const(uint)* is not supported in CTFE this is line 39 (https://github.com/repeatedly/xxhash-d/blob/master/src/xxhash.d#L39): > auto srcPtr = cast(const(uint)*)source.ptr; I'm on Windows 10 64-bit machine. |
May 21, 2018 Re: Can I work out error: reinterpreting cast from const(ubyte)* to const(uint)* is not supported in CTFE? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dr.No | On Monday, May 21, 2018 18:13:26 Dr.No via Digitalmars-d-learn wrote:
> I'm trying to do some hashing at compile time with xxhash algorithm but I get this error:
>
> ..\..\..\AppData\Local\dub\packages\xxhash-master\xxhash\src\xxhash.d(39,3
> 7): Error: reinterpreting cast from const(ubyte)* to const(uint)* is not
> supported in CTFE
>
> this is line 39
>
> (https://github.com/repeatedly/xxhash-d/blob/master/src/xxhash.d#L39):
> > auto srcPtr = cast(const(uint)*)source.ptr;
>
> I'm on Windows 10 64-bit machine.
You can't do any kind of pointer manipulaton or related casts in CTFE. So, you can't reinterpet one type as another at compile time. You would need a different hashing algorithm for CTFE - e.g.
if(__ctfe)
{
... do something to calculate a hash
}
else
{
... calculate the hash the current way
}
- Jonathan M Davis
|
Copyright © 1999-2021 by the D Language Foundation