467,077 Members | 1,033 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

(unsafe) Converting char*[] -> char** for PInvoke call

I am using PInvoke to call a function from a native C library.
As one of its parameters, it takes an array of strings in the form of char**.

I put the call into an unsafe block and created my array with a char*[] type. However, the compiler complains that it cannot conver
char*[] to char** when I try to make the call to the native function.

How can I do this conversion? Or is there a better way than using an unsafe block (using a System.String[] perhaps?)

--
Adam Clauss
ca*****@tamu.edu
Nov 16 '05 #1
  • viewed: 2116
Share:
1 Reply
Adam,
I put the call into an unsafe block and created my array with a char*[] type. However, the compiler complains that it cannot conver
char*[] to char** when I try to make the call to the native function.
Can't you change the parameter type to char*[] then?

Or is there a better way than using an unsafe block (using a System.String[] perhaps?)


It depends on what the parameter is for (input or output, who
allocates the memory and so on).

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Elidel | last post: by
3 posts views Thread by Andre | last post: by
4 posts views Thread by Jon Milner | last post: by
17 posts views Thread by Bradley1234 | last post: by
1 post views Thread by Z | last post: by
reply views Thread by Nuno Magalhaes | last post: by
reply views Thread by =?Utf-8?B?U2hhcm9u?= | last post: by
reply views Thread by colin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.