Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2005

Tip: Looking for answers? Try searching our database.

Quick way to go from  double* to Double []

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
apm - 23 Oct 2005 19:26 GMT
Is there a way to go from a pointer to an unmanaged array of double to a
managed Array of Double without having to copy the values?  The unmanaged
code calls back into managed code. The unmanaged callback arguments include
arrays of double. The delegate used to define the callback function requires
managed arguments.

The caller wants

void __cdecl func(double* x)

It actually needs to call

_delegate void func(Double x[])

Thanks in advance.

Regards,
DTC
Carl Daniel [VC++ MVP] - 23 Oct 2005 21:55 GMT
> Is there a way to go from a pointer to an unmanaged array of double to a
> managed Array of Double without having to copy the values?  The unmanaged
[quoted text clipped - 9 lines]
>
> _delegate void func(Double x[])

You need to allocate the array in managed code in the first place, then you
can get a double __in* pointing into the managed array that can be passed to
your native code.

If the array must be allocated by native code, there's no way to reflect it
into the managed world as an array without copying the values, AFIAK
(although I do recall reading discussion of possibly adding such a facility
to the CLR, I don't think it was ever done).

-cd

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.