Suppose I did this:
Assuming the sytax is correct (not sure about that :D), could I say "stuff.var = true;"? And then, could I manipulate var2 as an int?Code:struct Stuff
{
var : 1
var2 : 4
unused : 3
};
Stuff stuff;
Printable View
Suppose I did this:
Assuming the sytax is correct (not sure about that :D), could I say "stuff.var = true;"? And then, could I manipulate var2 as an int?Code:struct Stuff
{
var : 1
var2 : 4
unused : 3
};
Stuff stuff;
The syntax is incorrect, but yeah, you are on the right track. You still have to give your struct members datatypes! Also, You don't need to put in the "unused" 3 bit wide variable (unless you are planning on using it, , which i'm doubting from the name, or for some reason just want those 3 bits to be of a certain value). Your structure will automatically be padded, just like any other case.
Also, it appears as though you want var to be used as a bool. You can declare it as a bool then!Code:struct Stuff
{
int var : 1,
var2 : 4,
unused : 3;
};
Is all you need.Code:struct Stuff
{
bool var : 1;
int var2 : 4;
};
Oh, I get it :) so you still need the type to tell it how to handle the variables, right?
Oh, and by the way, the variable size is in bits, right (i.e. "bitfields")?