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

unnamed variable as place holder inside struct

Does any one know how to create an unnamed variable for place holder in a struct? I know you can do it in bitfiled.

Example:

struct S
{
   int a;
   int b;
   int[5]; //reserved 5 ints but dont' need to name it.
   int c;
   int d;

   int  bit0 : 1;
   int       : 6;
   int  bit7 : 1;

}
</pre?

Parents
  • Would this work?

    Not really --- keeping in mind that this method relies on the magic number 8 having its usual meaning of "number of bits in a byte", and that I don't think anonymous bitfields are supposed to have a width assigned to them --- they're supposed to be used to "flush" one machine word, so the next bitfield will start in a word of its own. Neither am I convinced they're guaranteed to start a new one if the next bit would have been in a fresh word already.

    To summarize: the problem is in what the OP is trying to do, not in Keil preventing him from doing it.

Reply
  • Would this work?

    Not really --- keeping in mind that this method relies on the magic number 8 having its usual meaning of "number of bits in a byte", and that I don't think anonymous bitfields are supposed to have a width assigned to them --- they're supposed to be used to "flush" one machine word, so the next bitfield will start in a word of its own. Neither am I convinced they're guaranteed to start a new one if the next bit would have been in a fresh word already.

    To summarize: the problem is in what the OP is trying to do, not in Keil preventing him from doing it.

Children