voidptr should be considered as an unmanaged type
https://github.com/dotnet/fsharp/issues/11424
Currently F# does not treat voidptr as an unmanaged type. Therefore types like nativeptr<voidptr>, etc. cause compiler errors.
However on IL level this works and C# libraries (e.g. Silk.NET.OpenGL) expose methods expecting this kind of argument (which currently can't be created in F# due the above)

The existing way of approaching this problem in F# is to make use of C# to wrap around problematic methods.
Pros and Cons
The advantages of making this adjustment to F# are
- Consistency with C#
- Convenience
- Less surprises
The disadvantages of making this adjustment to F# are that native interop is not an area F# focuses on. However, it's still beneficial to unblock scenarios where we must make use of C#.
Extra information
Estimated cost (XS, S, M, L, XL, XXL): XS to S
Related suggestions: https://github.com/dotnet/fsharp/issues/11424
Affidavit (please submit!)
Please tick this by placing a cross in the box:
- [x] This is not a question (e.g. like one you might ask on stackoverflow) and I have searched stackoverflow for discussions of this issue
- [x] I have searched both open and closed suggestions on this site and believe this is not a duplicate
- [x] This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.
Please tick all that apply:
- [x] This is not a breaking change to the F# language design
- [x] I or my company would be willing to help implement and/or test this
For Readers
If you would like to see this issue implemented, please click the :+1: emoji on this issue. These counts are used to generally order the suggestions by engagement.
Agree, in practice I currently often just fall back to nativeint to work around type juggling headaches that arise because of this.
Agreed, this feels like something that's just the right thing to do. I have approved this in principle. While I cannot speak for the priority of the team to implement, I think this would also make a fine contribution to F# vNext.