"Error: `TypeInfo` cannot be used with -betterC" on a CTFE function
Steven Schveighoffer
schveiguy at gmail.com
Wed Apr 10 17:44:57 UTC 2024
On Tuesday, 9 April 2024 at 23:50:36 UTC, Richard (Rikki) Andrew
Cattermole wrote:
> On 10/04/2024 11:21 AM, Liam McGillivray wrote:
>> 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.
>>>
>>> So that function is being used for both, and hence uses GC
>>> (appending).
>>
>> Are you sure that string appending was really the problem that
>> caused the "TypeInfo" build error? I forgot about this, but I
>> had already had a working CTFE function with string appending
>> before adding the new one that lead to this error. The symbols
>> that it generates could be used in the program compiled with
>> `betterC`.
>
> No, for a string it shouldn't trigger the need for TypeInfo.
> But that wouldn't have worked regardless.
Array appending calls a runtime function which accepts `TypeInfo`
(In this case, `TypeInfoGeneric!char`). So this does indeed
involve `TypeInfo`. But also, even if `TypeInfo` weren't
involved, it also needs the GC which is unavailable with betterC.
It's just that the `TypeInfo` error happens first.
The move to use templates instead of `TypeInfo` is slowly
happening.
-Steve
More information about the Digitalmars-d-learn
mailing list