Re: "Error: `TypeInfo` cannot be used with -betterC" on a CTFE function

2024-04-07 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Unfortunately runtime and CTFE are the same target in the compiler. So that function is being used for both, and hence uses GC (appending). ```d template Foo(Args) { enum Foo = () { return Args.init; }(); } ``` Something like that should work instead.

"Error: `TypeInfo` cannot be used with -betterC" on a CTFE function

2024-04-07 Thread Liam McGillivray via Digitalmars-d-learn
I'm making a modification to a D binding for a C library. I made a CTFE function which takes a function declaration with one or more `const(char)*` or `char*` parameters and makes an overload that accepts D strings. While this function is only used during compile time, unfortunately, I have

Re: impure

2024-04-07 Thread MrJay via Digitalmars-d-learn
On Sunday, 24 March 2024 at 07:41:41 UTC, Dom DiSc wrote: I'm creating a library that is completely pure, but it doesn't compile with pure: at the top because of one impure unittest (which uses random to test some things only probabilistic)! So do I really need to declare every function pure

Re: "Error: `TypeInfo` cannot be used with -betterC" on a CTFE function

2024-04-07 Thread Liam McGillivray via Digitalmars-d-learn
On Sunday, 7 April 2024 at 08:59:55 UTC, Richard (Rikki) Andrew Cattermole wrote: Unfortunately runtime and CTFE are the same target in the compiler. :-( Will this ever be changed? ```d template Foo(Args) { enum Foo = () { return Args.init; }(); } ```