Compile time int to string conversion in BetterC

Ogi at
Wed Aug 17 08:44:30 UTC 2022

It’s 2022 already and BetterC still imposes limits at compile 
time and makes things awkward.

I have 3 integer enums that represents my library version. And I 
want to generate a "1.2.3" enum from them. This is a trivial 
thing to do in standard D but I can’t find a way to do it with 
BetterC enabled. I can’t use `to`, `text`, `sformat` or 
`toChars`, as none of them is compatible with BetterC. And I 
can’t use `sprintf` either because ‘stdc’ is not available at 
compile time.

On the other hand, string to integer conversion is simple: just 
‘mixin’ it! So as a workaround, I put numbers into private string 
enums, and the integer enums are generated from them. But this is 
not nice.

Maybe I’m missing something?

More information about the Digitalmars-d-learn mailing list