Are there double * and double ** soft types? FROM#

I have a question about sorting C ++ arrays in C #. Automatically converts double * to double []?

I know double is a type of blittable, so double from C ++ is the same as double from C #. What about double **, does it convert to double [,]?

I have the following unmanaged function: int get_values ​​(double ** param, int sz)

where param is a pointer to a doubling array and sz size.

How can I DLLImport this function in C #?

Thank you in advance

+3
source share
3 answers

The declaration does not make sense. It would be wise if the function accepts a pointer to an array of doubles, but then the declaration would be

int get_values(double* array, int size);

, , , . P/Invoke :

[DllImport("blah.dll")]
private static extern int get_values(double[] array, int size);

, .

double ** . , , . , . , , .

, , .

+2

:

:

blittable , . , .

0

double* double[] :

void f(double* p);
void g(double p[]);
void h(double p[10]); // even if you supply a size! (it ignored)

void i(double (&a)[10]); // now this is different

:

void j() {
  double a[10]; // sizeof a == sizeof(double) * 10
  double* p; // sizeof p == sizeof(void*)
}

double** vs double*[], double[][] ( ) , ( , ).

, double**, . double* ?

int get_values(double* array, int size);

void func() {
  double a[10];
  get_values(a, 10);
}

( , DLLImport, .)

0

Source: https://habr.com/ru/post/1723402/


All Articles