char[] a;
auto b = cast(void*)a;
auto c = cast(char[])b; // Error: e2ir: cannot cast b of type void* to
type char[]
On Fri, Feb 24, 2012 at 08:34:19PM +0100, simendsjo wrote:
char[] a;
auto b = cast(void*)a;
auto c = cast(char[])b; // Error: e2ir: cannot cast b of type
void* to type char[]
D arrays are not the same as C arrays. D arrays also include length in
addition to the pointer, so you
On Fri, 24 Feb 2012 20:34:19 +0100, simendsjo wrote:
char[] a;
auto b = cast(void*)a;
auto c = cast(char[])b; // Error: e2ir: cannot cast b of type void*
to
type char[]
Arrays have a length--you need to cast the pointer to a char*, then slice
it.
On Fri, 24 Feb 2012 20:42:20 +0100, Justin Whear
jus...@economicmodeling.com wrote:
On Fri, 24 Feb 2012 20:34:19 +0100, simendsjo wrote:
char[] a;
auto b = cast(void*)a;
auto c = cast(char[])b; // Error: e2ir: cannot cast b of type void*
to
type char[]
Arrays have a
24.02.2012 21:34, simendsjo пишет:
char[] a;
auto b = cast(void*)a;
auto c = cast(char[])b; // Error: e2ir: cannot cast b of type
void* to type char[]
Generally, you should not cast a struct to pointer and vise-versa.
Besides, size of array structure is larger than size of
24.02.2012 21:34, simendsjo пишет:
char[] a;
auto b = cast(void*)a;
auto c = cast(char[])b; // Error: e2ir: cannot cast b of type
void* to type char[]
[...]
Just out of curiosity, what are you trying to accomplish with this cast?
In almost all normal D code, there's no need for
On 02/24/2012 11:44 AM, simendsjo wrote:
On Fri, 24 Feb 2012 20:42:20 +0100, Justin Whear
jus...@economicmodeling.com wrote:
On Fri, 24 Feb 2012 20:34:19 +0100, simendsjo wrote:
char[] a;
auto b = cast(void*)a;
auto c = cast(char[])b; // Error: e2ir: cannot cast b of type void*
to
type
On Fri, 24 Feb 2012 20:56:18 +0100, Ali Çehreli acehr...@yahoo.com wrote:
On 02/24/2012 11:44 AM, simendsjo wrote:
On Fri, 24 Feb 2012 20:42:20 +0100, Justin Whear
jus...@economicmodeling.com wrote:
On Fri, 24 Feb 2012 20:34:19 +0100, simendsjo wrote:
char[] a;
auto b = cast(void*)a;
auto
On Fri, 24 Feb 2012 20:56:22 +0100, H. S. Teoh hst...@quickfur.ath.cx
wrote:
24.02.2012 21:34, simendsjo пишет:
char[] a;
auto b = cast(void*)a;
auto c = cast(char[])b; // Error: e2ir: cannot cast b of type
void* to type char[]
[...]
Just out of curiosity, what are you trying to
On Fri, Feb 24, 2012 at 11:56:18AM -0800, Ali Çehreli wrote:
[...]
char[1] a;
auto c = a.ptr[0..a.length];
[...]
Hey, that's an awesome way to implement copy-on-write static arrays!
I'll have to use that sometime. :)
T
--
Sometimes the best solution to morale problems is just to
On 2/24/12, simendsjo simend...@gmail.com wrote:
I don't get it. This gives me a dynamic array, not a static:
char[1] a;
auto b = cast(void*)a;
auto c = (cast(char*)b)[0..1];
c.length = 10; // auch!
You can do:
char[1] c = (cast(char*)b)[0..1];
On Fri, 24 Feb 2012 21:36:21 +0100, Andrej Mitrovic
andrej.mitrov...@gmail.com wrote:
On 2/24/12, simendsjo simend...@gmail.com wrote:
I don't get it. This gives me a dynamic array, not a static:
char[1] a;
auto b = cast(void*)a;
auto c = (cast(char*)b)[0..1];
c.length =
12 matches
Mail list logo