Re: two-dimensional C array and its analog in D

2012-08-08 Thread Alexandr Druzhinin
08.08.2012 22:21, Ali Çehreli пишет: I looked at its online documentation: count is also an array that tells the lengths of individual rows of indices, right? So in reality the data is a dynamic ragged array? (I've never used that function before.) Yes, it is. > If I declare indices like

Re: two-dimensional C array and its analog in D

2012-08-08 Thread Ali Çehreli
On 08/08/2012 07:12 AM, Alexandr Druzhinin wrote: > 08.08.2012 16:29, bearophile пишет: >>> That C code doesn't look correct, because the given data contains no >>> pointers. >> >> But this C code compiles: >> >> >> void foo(const void** data) {} >> int data[2][3]; >> int main() { >> foo(data); >>

Re: two-dimensional C array and its analog in D

2012-08-08 Thread BLM768
I mean that I call C function from D code. And C function takes void** pointer as its argument. In C this means array of array, but if I pass D two-dimensional array it doesn't work (but compiles). I'm pretty sure that the issue is D's internal implementation of 2-dimensional arrays. From w

Re: two-dimensional C array and its analog in D

2012-08-08 Thread Alexandr Druzhinin
08.08.2012 12:13, Ali Çehreli пишет: This seems to work: import std.stdio; void main() { enum M = 3; enum N = 4; int[M][N] data; data[0][0] = 42; writeln(data); } The output: [[42, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] Ali I mean that I call C function from D

Re: two-dimensional C array and its analog in D

2012-08-08 Thread Alexandr Druzhinin
08.08.2012 16:29, bearophile пишет: That C code doesn't look correct, because the given data contains no pointers. But this C code compiles: void foo(const void** data) {} int data[2][3]; int main() { foo(data); return 0; } Bye, bearophile As I know in C an array is equal to pointer,

Re: two-dimensional C array and its analog in D

2012-08-08 Thread bearophile
That C code doesn't look correct, because the given data contains no pointers. But this C code compiles: void foo(const void** data) {} int data[2][3]; int main() { foo(data); return 0; } Bye, bearophile

Re: two-dimensional C array and its analog in D

2012-08-08 Thread bearophile
Alexandr Druzhinin: there is the following C function: void foo(const void** data); in C I can do: int data[N][M]; data[0][0] = ..; data[0][1] = ..; data[1][0] = ..; data[1][1] = ..; foo(data); // for C code it works and in D code it doesn't (compile, but do nothing) That C code doesn't

Re: two-dimensional C array and its analog in D

2012-08-07 Thread Ali Çehreli
On 08/07/2012 11:07 PM, Alexandr Druzhinin wrote: > Hello, > there is the following C function: > > void foo(const void** data); > > in C I can do: > > int data[N][M]; > > data[0][0] = ..; > data[0][1] = ..; > data[1][0] = ..; > data[1][1] = ..; > > foo(data); // for C code it works and in D code

two-dimensional C array and its analog in D

2012-08-07 Thread Alexandr Druzhinin
Hello, there is the following C function: void foo(const void** data); in C I can do: int data[N][M]; data[0][0] = ..; data[0][1] = ..; data[1][0] = ..; data[1][1] = ..; foo(data); // for C code it works and in D code it doesn't (compile, but do nothing) I've "solved" the problem like this