This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM Cotex-M0 memory allocation for structure array with bitfeilds

I want to use a structure as given below on my ARM Cortex-M0, I am using C programming.

struct path_table_t {

uint8_t lut_index;

uint8_t flag : 1; };

'flag' field is made to be single bit by bit fields.How will be the memory allocation for the array of above mentioned structure will happen.

Will I get the benefit of bit fields as saving in total memory

Parents
  • How will be the memory allocation for the array of above mentioned structure will happen.

    Ignore the bitfield specifier and just read the structure - you'll get two uint8_t types allocated in memory.

    Will I get the benefit of bit fields as saving in total memory

    No - it's just a more convenient syntax than manually performing AND  and OR mask operations - but there is no "magic" here.

    HTH,
    Pete

Reply
  • How will be the memory allocation for the array of above mentioned structure will happen.

    Ignore the bitfield specifier and just read the structure - you'll get two uint8_t types allocated in memory.

    Will I get the benefit of bit fields as saving in total memory

    No - it's just a more convenient syntax than manually performing AND  and OR mask operations - but there is no "magic" here.

    HTH,
    Pete

Children
No data