Opened 3 years ago

Last modified 8 months ago

#12149 new bug

Support bit-fields

Reported by: facundo.dominguez Owned by:
Priority: normal Milestone:
Component: hsc2hs Version: 8.0.1
Keywords: bit-fields Cc: mboes, qnikst
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Having C type like:

typedef struct S {
  int f0: 1;
  int f1: 15;
} S;

and hsc code like

#{peek S, f0} p

Causes hsc2hs to fail with

error: attempt to take address of bit-field structure member 'f0'

Apparently this is an error from gcc, which cannot provide the address of bit-fields. However, in Haskell we are not interested in the address of the bit-field but in its value.

It would be useful to have a way to get and set the values of these fields.

Some former discussion here

Change History (1)

comment:1 Changed 8 months ago by andrewthad

This just bit me as well. On linux, iphdr has a bit field, and I'm struggling to find a good way to peek and poke at these.

Note: See TracTickets for help on using tickets.