• brian@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    5 days ago

    things that store it as word size for alignment purposes (most common afaik), things that pack multiple books into one byte (normally only things like bool sequences/structs), etc

    • timhh@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      1 day ago

      things that store it as word size for alignment purposes

      Nope. bools only need to be naturally aligned, so 1 byte.

      If you do

      struct SomeBools {
        bool a;
        bool b;
        bool c;
        bool d;
      };
      

      its 4 bytes.

      • brian@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        1 day ago

        sure, but if you have a single bool in a stack frame it’s probably going to be more than a byte. on the heap definitely more than a byte