Thread overview |
---|
November 09, 2020 CTFE using compiler intrinsics but without phobos/druntime. | ||||
---|---|---|---|---|
| ||||
I like metaprogramming and I write a tons of compile-time evaluated code. Important thing for me is that the usual math functions like `sin` from `core.math` also can be evaluated at compile time dispite of its source code actually does not available at compile time. Now I porting my project to bare-metal. Currently there is nothing druntime/phobos support for that case, which means I cannot use `core.math` as usual. I was trying to work around it by creating stub module similar to `core.math` but this does not work nor with GDC nor LDC. Note, I do not need math at runtime I just need it for compiling. Anyone known an easy way to get CTFE work in that case? |
November 09, 2020 Re: CTFE using compiler intrinsics but without phobos/druntime. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kayo | Hmm... It seems this works when I defines `sin` function for `real` arg like so: module core.math; public: @nogc: pure: nothrow: @safe: real sin(real x); |
November 09, 2020 Re: CTFE using compiler intrinsics but without phobos/druntime. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kayo | On Monday, 9 November 2020 at 18:19:42 UTC, Kayo wrote: > Hmm... > It seems this works when I defines `sin` function for `real` arg like so: Currently the compiler has a list of built in functions, making them available at CTFE even if their source is missing. https://github.com/dlang/dmd/blob/5fda4ea088f70afb99818482e8482771758136a2/src/dmd/func.d#L67 https://github.com/dlang/dmd/blob/master/src/dmd/builtin.d The current list includes functions from `std.math`, `core.math` and `core.bitop`. If you think something is missing, you can file an issue and / or open a pull request. |
Copyright © 1999-2021 by the D Language Foundation