Reputation: 2647
Have:
[DllImport("OpenAL32.dll")]
static extern void alcOpenDevice(char*[] devicename);
Wanna send the name to this function like smth that:
char[] data = "Hello!".ToCharArray();
char*[] txt = &data;
But getting the errors:
cannot implicitly convert type
char[] *
tochar * []
(funny error, because C# compiler refuses to define char[] *
in /unsafe mode also :) )
Cannot take the address of, get the size of, or declare a pointer to a managed type (
char[]
)
PS
When does char
become managed? It's a struct, isn't it?
public struct Char : IComparable, IConvertible, IComparable<char>, IEquatable<char>
Although compiler showed info about declaring the pointer to a managed type (char[]
). I can only suggest that when the type is an array CLR may present it like a managed type, but it sounds very crazy.
Upvotes: 1
Views: 6339
Reputation: 1
If you use char[]
to char*
You missed fixed
statement:
char[] data = "Hello!".ToCharArray();
fixed (char* dataPtrs = data)
{
// Logic here ...
}
I hope that my code helps you.
If you want to use char*[]
from char**
( char Double Pointer ) - I will look for resolving...
Upvotes: 0
Reputation: 23505
alcOpenDevice does not take char*[]
or char**
, it takes char*
, which you should specify as a string
. It also returns a handle.
[DllImport("OpenAL32.dll", CharSet = CharSet.Ansi)]
static extern IntPtr alcOpenDevice(string devicename);
Upvotes: 6