Blittable types
This article provides insufficient context for those unfamiliar with the subject.(May 2018) |
Blittable types are
Origin
A memory copy operation is sometimes referred to as block transfer, shortened to bit blit (and dedicated hardware to make such a transfer is called a blitter). Blittable is a .NET-specific term expressing whether it is legal to copy an object using a block transfer.
Interoperability overview
Interoperability can be bidirectional sharing of data and methods between
Blittable types defined
A blittable type is a data type that does not require special attention from the interop marshaler because by default it has a common representation in managed and unmanaged memory. By
System.Byte
System.SByte
System.Int16
System.UInt16
System.Int32
System.UInt32
System.Int64
System.UInt64
System.IntPtr
System.UIntPtr
System.Single
System.Double
Additionally, one-dimensional
If a type is not one of the blittable types, then it is classified as non-blittable. The reason a type is considered non-blittable is that for one representation in managed memory, it may have several potential representations in unmanaged memory or vice versa. Alternatively, there may be exactly one representation for the type in both managed and unmanaged memory. It is also often the case that there simply is no representation on one side or the other. The following are some commonly used non-blittable types in the .NET Framework:[2]
System.Boolean
System.Char
System.Object
System.String
There are many more blittable and non-blittable types, and user-defined types may fit in either category depending on how they are defined (MSDN).
Usage
This very restrictive notion of blittable types appears to limit the usefulness of the interoperability services provided by .NET, but this is not so. While blittable types allow a straightforward definition of interoperable types, various ways exist to explicitly define how a non-blittable type should be converted by the interop marshaler.
See also
- Platform Invocation Services (P/Invoke)
- .NET Framework
- List of CLI languages
- COM
- Interoperability
- POD
References
- ^ "MSDN Magazine - P/Invoke Revisited". Msdn.microsoft.com. Retrieved 2011-12-05.
- ^ a b "MSDN - Blittable and Non-Blittable Types". Msdn.microsoft.com. Retrieved 2016-02-05.
- ^ "MSDN - Interop Marshaling Overview". Msdn.microsoft.com. Retrieved 2016-02-05.
- ^ "MSDN - .NET Interoperability". Msdn2.microsoft.com. Retrieved 2011-12-05.