We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import std.stdio; import core.stdc.string;
alias cstring = immutable(char)*;
byte[] arr(T : cstring)(T value) { return value is null ? cast(byte[])[0x00] : (cast(byte*)value)[0 .. strlen(value) + 1]; }
void main(string[] args) { cstring str = std.string.toStringz("string"); writeln(str.arr); }
The text was updated successfully, but these errors were encountered:
The output of the program is:
[115, 116, 114, 105, 110, 103, 0]
with dmd 2.063.2, dmd trunk and ldc trunk. Does your compiler output something different?
Sorry, something went wrong.
@redstar I am unable to compile it with ldc 1.0.11, I will try it with latest git version
compile output: main.d(13): Error: no property 'arr' for type 'immutable(char)'
With latest ldc from git It seems compile OK, so I close this issue.
Merge pull request #441 from dawgfoto/SharedRuntime_6
f16f128
SectionGroup support for TLS
No branches or pull requests
import std.stdio;
import core.stdc.string;
alias cstring = immutable(char)*;
byte[] arr(T : cstring)(T value) {
return value is null ? cast(byte[])[0x00] : (cast(byte*)value)[0 .. strlen(value) + 1];
}
void main(string[] args)
{
cstring str = std.string.toStringz("string");
writeln(str.arr);
}
The text was updated successfully, but these errors were encountered: