Hi, I like to print the strings from a C function that returns
const(dchar*), but I can't make the conversion to dstring. I can
convert vice versa by:
dstring text = "Hello";
const(dchar)* str = toUTFz!(const(dchar)*)(text);
// passing it to C function prints Hello
However, I don't have the id
On Tuesday, 24 June 2014 at 17:59:41 UTC, Steven Schveighoffer
wrote:
const(dchar *)x = ...;
// assuming 0 terminated
dstring text = x[0..x.strlen].idup;
-Steve
const(dchar)* x = "Hello\0";
dstring text = x[0..x.strlen].idup;
writeln(text);
Error: no property 'strlen' for type 'const(dchar)*'
On Tuesday, 24 June 2014 at 18:34:31 UTC, Chris Cain wrote:
You can do what he said, but you'll have to write your own
strlen function:
something like:
size_t strlen(in dchar* s) pure @system nothrow
{
size_t pos = 0;
dchar term = '\0';
while(s[pos] != term)
Hi, In the development of my library, I'm in a position where I
need to add support for multiple compilers. For instance,
supporting both the assembly of LDC/DMD and GDC. I want to do
something like:
version(DigitalMars && LDC)
{
}
However, it doesn't compile which forces me to rewrote the sa
On Wednesday, 25 June 2014 at 20:30:28 UTC, Justin Whear wrote:
I think you mean ||, not &&. The best way I know around this
is to
define enums:
version (DigitalMars)
enum compiler_DigitalMars = true;
else
enum compiler_DigitalMars = false;
//... similar for LDC
static if (compiler_Dig
Hi,
I noticed that in Andrei's talks and his book, he used braces on
the same line of delcaration, however Phobos and other D
libraries I know use braces on their own line. Now I'm in a
position where I need to take decision on coding style of my
library and I get accustomed to use braces on
On Saturday, 12 July 2014 at 19:09:44 UTC, seany wrote:
Please consider the following
struct arc(T,U)
{
T some_var;
U someother_var;
}
/* things */
class myclass
{
this(){}
~this(){}
void MYfunction()
{
arc!(string, string[]) * a;
a.some_var = "hello";
}
}
void main()
{
On Saturday, 12 July 2014 at 19:19:28 UTC, seany wrote:
For reasons further down in the software, I need to do this
with a pointer. How do I do it with a pointer, please?
I don't know what are you trying to achieve, but if that's what
you want, you can do:
void MYfunction()
{
auto strArr
On Saturday, 12 July 2014 at 19:32:48 UTC, seany wrote:
do I have to initialize all variables of the struct? or may I
also use a this(){} in the struct and initialize only those
which are known at a given moment?
You can initialize in constructor this(), but you can't
initialize partial field
On Saturday, 12 July 2014 at 19:42:13 UTC, Ali Çehreli wrote:
Actually, that works too but members must be initialized from
the beginning. The trailing ones are left with .init values:
struct S
{
int i;
string s;
}
void main()
{
auto s = new S(42);
static assert(is (typeof(s) =
On Saturday, 12 July 2014 at 19:35:11 UTC, anonymous wrote:
There is another stylistic choice which I do find confusing:
capitalized identifiers for non-types, e.g. variables and
functions. Please don't do that.
Agreed about variables and functions. However I personally prefer
to use PascalCas
On Sunday, 13 July 2014 at 10:18:23 UTC, Joseph Rushton Wakeling
via Digitalmars-d-learn wrote:
However, I do think there's value in deliberately matching the
code style of the standard library, as it extends the volume of
public D code with a common style.
So unless you have a strong personal
On Sunday, 13 July 2014 at 16:10:31 UTC, Gary Willoughby wrote:
Here is the 'official' style that is followed by most people
including me.
http://dlang.org/dstyle.html
Unrelated to my original question. I already read that before
asking.
On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote:
There are a lot of discussions in the forums about how @property
should or could be implemented. But I can't seem to find
anything
that explains why or when I should use @property with the
current
compiler. Can anyone explain why and when I
On Saturday, 6 September 2014 at 11:13:20 UTC, Russel Winder via
Digitalmars-d-learn wrote:
OK I installed LDC pre-built on MinGW for Windows on Windows
and then
Installed MinGW for Windows but when I run ldc2 it tells me
libgcc_s_dw2-1.dll is missing.
Is this problem soluble by any means other
Hi,
I don't know if this has been mentioned before, but I found two
strange cases where UFCS doesn't work.
Case # 1: When the functions for UFCS are defined inside main
scope
class Rect {
int x = 20;
int y = 20;
}
void main() {
import std.stdio : writeln;
int area(
On Tuesday, 9 September 2014 at 18:46:31 UTC, ketmar via
Digitalmars-d-learn wrote:
UFCS is not working for nested functions. this is not a bug, it
was
designed this way. the same for 'with', i believe.
Apparently it is a bug that UFCS doesn't work with 'with'
statement.
https://issues.dlang.o
On Thursday, 11 September 2014 at 17:37:24 UTC, Nordlöw wrote:
Ok, thanks. And I guess vibe.d can do this aswell without
external dependencies, right?
I'm also interested to know how this can be done with vibe.d...
18 matches
Mail list logo