Utilizing .NET 9, concentrating on iOS, I’ve one thing like this:
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public delegate bool MyCallback();
// ...
personal static MyCallback _MyCallback = __MyCallback;
// ...
[ObjCRuntime.MonoPInvokeCallback(typeof(MyCallback))]
personal static bool __MyCallback()
{
return false;
}
On the native facet:
typedef signed char BOOL;
typedef BOOL (*fnMyCallback)();
//
printf("sizeof(BOOL)=%zun", sizeof(BOOL));
if (!context->myCallback()
{
printf("direct verify is FALSEn");
}
else
{
printf(TAG, "direct verify is TRUEn");
}
Output is
sizeof(BOOL)=1
direct verify is TRUE
So, we verify that the worth we’re coping with is 1 byte on each managed and unmanaged sides. Why is it incorrectly evaluated as true
?
This solely happens on iOS ARM64 in launch builds.
The C compiler is no matter we have now within the Xcode 16.4 toolchain.