j'essaie d'appeler un DllImport sur la fonction suivante Alsa (du documentation:P/Invoke EntryPointNotFoundException lorsqu'on essaie d'attribuer des conteneurs de pointeur
#define snd_seq_client_info_alloca(ptr) __snd_alloca(ptr, snd_seq_client_info)
allouer un conteneur de snd_seq_client_info_t sur la pile
Voici une implémentation que j'ai trouvée en C++ en lisant le code d'un application similaire à ce que je veux accomplir en Mono:
snd_seq_client_info_t* cinfo;
snd_seq_client_info_alloca(&cinfo);
Et voici ce que j'ai jusqu'à présent, mais il ne fonctionne pas:
[DllImport(libasound.so.2)]
private static extern void snd_seq_client_info_alloca(out IntPtr ptr);
internal static void MyFunction()
{
IntPtr clientInfo = IntPtr.Zero;
snd_seq_client_info_alloca(out clientInfo);
// and then some more ...
}
mais je reçois l'exception suivante:
System.EntryPointNotFoundException: snd_seq_client_info_alloca
at (wrapper managed-to-native)
MonoMultiJack.ConnectionWrapper.Alsa.LibAsoundWrapper:snd_seq_client_info_alloca (intptr&)
'EntryPointNotFoundException' et' # define'. D'oh, parfois on néglige l'évidence. Merci. Au moins, il compile maintenant, je dois juste chercher le code de la bibliothèque pour la taille de la mémoire à allouer. – Residuum
Si vous voulez réellement stackalloc de C# vous pouvez aussi bien avec le mot clé stackalloc, comme ceci: int * block = stackalloc int [100]; –