Skip to content

Derive Bitfield instances for newtypes generated for typedefs #1289

@jorisdral

Description

@jorisdral

If we generate bindings for:

struct myStruct {
  int x : 2;
};

And then compile the bindings, everything works.

If instead we generate bindings for:

typedef int myInt;
struct myStruct {
  myInt y : 2;
};

Then we get a GHC error that roughly says:

     No instance for HsBindgen.Runtime.Bitfield.Bitfield MyInt
        arising from a use of HsBindgen.Runtime.HasCField.peekCBitfield

It should be simple to derive a Bitfield instance because MyInt is just a newtype around CInt.

Alternatively, we can disallow bit-field types like myInt. The C reference section on bit-fields seems pretty restrictive about what types are allowed as bit-fields, but implementations like gcc and clang seem to be more flexible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageRequires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions