I tested this case in detail, and experimentally found out the following:
If you marshal out a parameter that.
null
without an explicit Nullable
wrapper that is not supported by the marshalizer (e.g. float
).float*
(a pointer to a memory region that may be empty)Thus, if the marshalizable function writes null
there, then in C# the value of such a variable will be 0
(since out will declare it as 0
when initializing the variable, and null
will simply not be written).
As a result, we will have out float = 0
without any error on the part of dotnet
, so, answering your own question, in this case you can disregard the compliance with the original documentation and use the more convenient variant with out float
instead of out IntPtr
, but keep in mind that in case of an error, in the place where null
should be, there will be 0
.
I hope I was able to explain it in a clear way, and that people who have the same question will understand me.
I would be glad if people who are more knowledgeable in the subject would complement me if I have made a mistake.