Re: getting current DateTime

2014-12-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/31/14 1:41 AM, bitwise wrote: It would be nice if that cast was made implicit though. Just realizing now that DateTime doesn't have sub-second accuracy =/ Why do you need DateTime and not SysTime? I'm actually surprised it doesn't have that too... -Steve

Re: Passing string literals to C

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d extern(C) char* cpling(char* s); void callC() { writefln(%s,fromStringz(cpling(hello\0))); } or void callC() {

Passing string literals to C

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
What's best practice here? D strings are not null-terminated. char* cpling(char *s) { So toString(This i

Checking C return results against NULL

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
Am I missing a more agreeable way to check the return value of a C function against NULL. It's fine if it's a char*, but if it returns a pointer to some kind of struct, one has to go through and convert each instance of NULL to a cast of the appropriate return type. Eg cast(funnystruct*)0

Re: Checking C return results against NULL

2014-12-31 Thread Rikki Cattermole via Digitalmars-d-learn
On 1/01/2015 12:22 a.m., Laeeth Isharc wrote: Am I missing a more agreeable way to check the return value of a C function against NULL. It's fine if it's a char*, but if it returns a pointer to some kind of struct, one has to go through and convert each instance of NULL to a cast of the

Re: Checking C return results against NULL

2014-12-31 Thread Mike Parker via Digitalmars-d-learn
On 12/31/2014 8:29 PM, Rikki Cattermole wrote: On 1/01/2015 12:22 a.m., Laeeth Isharc wrote: Am I missing a more agreeable way to check the return value of a C function against NULL. It's fine if it's a char*, but if it returns a pointer to some kind of struct, one has to go through and

Re: Passing string literals to C

2014-12-31 Thread Daniel Kozák via Digitalmars-d-learn
V Wed, 31 Dec 2014 11:19:35 + Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d

Re: Passing string literals to C

2014-12-31 Thread Mike Parker via Digitalmars-d-learn
On 12/31/2014 8:19 PM, Laeeth Isharc wrote: Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d extern(C) char* cpling(char* s); void callC() {

Re: Passing string literals to C

2014-12-31 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 31 December 2014 at 11:45:33 UTC, Mike Parker wrote: On 12/31/2014 8:19 PM, Laeeth Isharc wrote: Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d extern(C) char*

Re: Passing string literals to C

2014-12-31 Thread Meta via Digitalmars-d-learn
On Wednesday, 31 December 2014 at 12:25:45 UTC, John Colvin wrote: String literals can implicitly convert to const(char)* or immutable(char)*. Neat. It doesn't appear to apply to array literals in general though... I believe this is a special case specifically for strings added for

regex on binary data

2014-12-31 Thread Darrell via Digitalmars-d-learn
So far attempts to run regex on binary data causes Invalid UTF-8 sequence. Attempts to pass ubyte also didn't work out.

Re: regex on binary data

2014-12-31 Thread Tobias Pankrath via Digitalmars-d-learn
On Wednesday, 31 December 2014 at 15:36:19 UTC, Darrell wrote: So far attempts to run regex on binary data causes Invalid UTF-8 sequence. Attempts to pass ubyte also didn't work out. I doubt using anything except (d,w)string is supported or possible.

Re: getting current DateTime

2014-12-31 Thread bitwise via Digitalmars-d-learn
Why do you need DateTime and not SysTime? I'm actually surprised it doesn't have that too... -Steve Initially I was looking for something that would be the equivalent to DateTime in C#. This now appears to be SysTime, not DateTime in D. It seems the only real reason to use DateTime is as

Re: Passing string literals to C

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
Thanks for the help. Laeeth

Re: Checking C return results against NULL

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
Thanks for the help. Laeeth

Re: regex on binary data

2014-12-31 Thread ketmar via Digitalmars-d-learn
On Wed, 31 Dec 2014 15:36:16 + Darrell via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: So far attempts to run regex on binary data causes Invalid UTF-8 sequence. Attempts to pass ubyte also didn't work out. current regex engine assumes that you are using UTF-8 encoded