-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
voidptr should be an unmanaged type #11424
Comments
The base library pointer types (e.g.: System.Int32*) including System.Void* are not a value types. So it seems that void** functionality is not yet available (as of dotnet/runtime#44968) > System.Type.GetType("System.Int32*").IsValueType;;
val it : bool = false > System.Type.GetType("System.Void*").IsValueType;;
val it : bool = false however System.IntPtr is: > System.Type.GetType("System.IntPtr").IsValueType;;
val it : bool = true |
In F# |
nativeptr is just s syntactic sugar around System.IntPtr (nativeint). What is missing is the System.Void (notice there is no pointer at the end) aka the > typeof<nativeptr<int>>.FullName;;
val it : string = "System.IntPtr" > typeof<System.Void>.IsValueType;;
val it : bool = true
|
Okay then maybe just allow |
You can always store an untyped pointer (nativeint) in the struct and have some helper methods / functions to map it to a proper type (worst case scenario is to call for an C# helper). What is the C# signature that you want to call (you can use simplified struct and some generic names)? |
I didn't look at the source yet but the F# type hover shows me a |
I can certainly work around that using a micro C# library but nonetheless it would be great to see that fixed somewhen... |
This is by design for F# 6, so perhaps add a language suggestion |
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)
Expected behavior
voidptr
should be treated as an unmanaged typeKnown workarounds
Sadly I couldn't come up with a workaround. If anyone has an idea I would be glad to hear it!
Related information
Tested on VS2019 with .NET5 and FSharp.Core 5.0.0
The text was updated successfully, but these errors were encountered: