C
C#2w ago
Stellar

✅ ILC AOT Analysis IL1005

So I'm working in a NativeAOT env, and I have this little chunk of code:
C++
[RuntimeImport("testGCC")]
extern static void* testGCC(void* a);
C++
[RuntimeImport("testGCC")]
extern static void* testGCC(void* a);
And that small two lines throws
ILC : AOT analysis error IL1005: Program.testGCC(Void*): Method will always throw because: Invalid IL or CLR metadata in 'Void* Program.testGCC(Void*)'
ILC : AOT analysis error IL1005: Program.testGCC(Void*): Method will always throw because: Invalid IL or CLR metadata in 'Void* Program.testGCC(Void*)'
My code using said function is
C#
string test = "Hello from GCC";

fixed (char* p = test)
{
char* result = (char*)testGCC(p);
Canvas.DrawString(result, 0, 56, Color.White);
}
C#
string test = "Hello from GCC";

fixed (char* p = test)
{
char* result = (char*)testGCC(p);
Canvas.DrawString(result, 0, 56, Color.White);
}
Any ideas?
2 Replies
Stellar
StellarOP2w ago
I know NativeAOT doesn't like ptrs to managed types being externed but I thought void was treated as a primitive? No clue if it's being confused by System.Void, but I'd assume not I'm wondering if I have to force IntPtr NVM it's because I forgot [MethodImpl(MethodImplOptions.InternalCall)]
MODiX
MODiX2w ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?