#Are bool parameters suported in burst function pointers?

1 messages · Page 1 of 1 (latest)

uncut cradle
worn pond
#

The bool type is really not supported, because it is not a blittable type in .NET (https://learn.microsoft.com/en-us/dotnet/framework/interop/blittable-and-non-blittable-types). Burst only support blittable types for this case.

.NET treats a managed bool type as 4 bytes when it maps across a p/invoke boundary (this is to match the way the Win32 C API treats bool types). But bool in C++ is only 1 byte. So something bool types seem to work, but code code in that case maybe reading four bytes, and instead of one byte, so those extra three bytes maight happen to be a value that makes sense (maybe zero, for example). But in other cases maybe those 3 bytes are used for something else, and now your code is reading bad data.

uncut cradle
worn pond
#

That might be OK, but I would play it safe and use byte instead.

#

I don't expect we will add errors or warnings, as .NET similarly does not warn or error for this.

#

Any time we get into p/invoke territory there are plenty of things to watch out for. 🙂

uncut cradle
worn pond
#

Yes