472,144 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,144 software developers and data experts.

(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
1 2220
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 Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.