BetterC + startsWith
Paul Backus
snarwin at gmail.com
Sat Feb 22 03:54:53 UTC 2020
On Saturday, 22 February 2020 at 02:01:25 UTC, SrMordred wrote:
> //-betterC
> import core.stdc.stdio;
> import std.algorithm;
>
> void main(){
> printf( "%d\n",startsWith("a","b") );
> }
>
> //Fails to compile with betterC, dmd/ldc2 last versions.
>
> Any reason for not work with betterC or should i file the issue
> ?
> (Find this on a bindbc lib, so i think that it may have worked
> previously)
The issue is that strings aren't input ranges in betterC [1], due
to autodecoding.
Normally you'd work around this using std.utf.byCodeUnit, but
that's currently broken, because std.utf attempts to import
core.exception.UnicodeException from druntime at module scope
[2], causing any betterC program that imports std.utf to fail
compilation.
So, for now, I think the best you can do is probably to
copy-paste byCodeUnit into its own source file, and use that
until std.utf is fixed.
[1] https://issues.dlang.org/show_bug.cgi?id=20139
[2]
https://github.com/dlang/phobos/blob/7a656e09d23507d0c404dabaa2c440a45e7c753d/std/utf.d#L65
More information about the Digitalmars-d-learn
mailing list