Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are .net Enums blittable types? (Marshalling)

Apparently there's a list of blittable types and so far I don't see Enums specifically on it. Are they blittable in general? Or does it depend on whether they are declared with a blittable base type?

//e.g.
internal enum SERVERCALL : uint
{
    IsHandled = 0,
    Rejected = 1,
    RetryLater = 2,
}

References exhausted:

  • "Blittable and Non-Blittable Types"
  • "Default Marshaling for Value Types"
like image 301
Tim Lovell-Smith Avatar asked Apr 07 '11 16:04

Tim Lovell-Smith


1 Answers

Enums are blittable types. From the enum keyword documentation:

Every enumeration type has an underlying type, which can be any integral type except char.

Because the underlying type is integral (all of which are on the list of blittable types), the enum is also blittable.

like image 88
Bradley Grainger Avatar answered Sep 19 '22 13:09

Bradley Grainger