Can't dynamically create c-style array?

Add-in Express™ Support Service
That's what is more important than anything else

Can't dynamically create c-style array?
 
Jason Crabtree




Posts: 19
Joined: 2007-01-23
I've got one last obstacle to getting my C++ add-in up and running. I'm using an API from some 3rd party software that uses c libraries. I need to pass a c-style array of doubles to it, but I can't create the array in my add-in. The add-in compiles okay, but it won't allocate the array when the add-in runs. I've tried:

//C++ approach
double (*data)[3] = new double [2][3];

and

//C approach
double *data;
data = (double *) calloc((size_t)(6), sizeof(double));

This might not be the appropriate forum for such a question, but I'm rewriting a previous C++ COM add-in, where the C approach above was used and worked, so it's somehow related to my add-in code. Any ideas on what's wrong? Or, is there another way to convert a System::Array to a c-style array?

Thanks
Posted 27 Jan, 2007 01:29:20 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Jason.

Is the API unmanaged library? If so, you should use the Marshal.AllocHGlobal method to allocate the memory block.


P.S. Note that we take up your forum requests in the order we receive them.
Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found.
Posted 29 Jan, 2007 06:47:00 Top
Jason Crabtree




Posts: 19
Joined: 2007-01-23
Yes, it is an unmanaged library, and yes, your suggestion worked great :D . Thanks for the quick reply again! I'm still getting the hang of working with managed C++.
Posted 30 Jan, 2007 15:00:25 Top