what am i doing wrong (union/struct)

okay, so i got this code:

struct audiobits{
  bool USB : 1;
  bool TF : 1;
  bool BT : 1;
  bool FX : 1;
  bool e : 1;
  bool f : 1;
  bool g : 1;
  bool h : 1;
};

union audiost {
  byte byt;
  struct audiobits;
};
audiost Audiostatus;
void setup() {
  // put your setup code here, to run once:
  Audiostatus.audiobits.e = true;
}

void loop() {
  // put your main code here, to run repeatedly:

}

and its wrong, but i don't know why, it gives me:

C:\Users\XXX\Documents\Arduino\sketch_jan29a\sketch_jan29a.ino: In function 'void setup()':

sketch_jan29a:19:15: error: invalid use of 'struct audiost::audiobits'

   Audiostatus.audiobits.e = true;

               ^~~~~~~~~

exit status 1
invalid use of 'struct audiost::audiobits'

this is my first time playing with unions/structures and it is baffling me...

struct audio bits is a type. You need to declare an actual variable and use it:

struct audiobits
{
  bool USB : 1;
  bool TF : 1;
  bool BT : 1;
  bool FX : 1;
  bool e : 1;
  bool f : 1;
  bool g : 1;
  bool h : 1;
};

union audiost
{
  byte byt;
  struct audiobits a;
};
audiost Audiostatus;
void setup()
{
  // put your setup code here, to run once:
  Audiostatus.a.e = true;
}

void loop()
{
  // put your main code here, to run repeatedly:
}

oh! thank you!

learning something new every day :slight_smile:
how can i use this with 2 bytes?