P
pozz
Hi all,
I want to use enum in this way:
typedef enum {
FIRST=1,
SECOND,
THIRD,
FORTH,
} order_t;
Now, if I declare a variable such as:
order_t n;
compiler consider n as an integer (2 byte in a 16 bit environment).
If I use only 4 values in an enumeration, n can be a simple unsigned
char, i.e. sizeof(n)=1. Is it possible to use enumeration and to
specify byte-length of that enumeration?
I know that I can write:
typedef enum {
.... (as before)
} order_t;
unsigned char n;
....
n=FIRST;
....
But in that way I lose the link between variable and enumeration.
I want to use enum in this way:
typedef enum {
FIRST=1,
SECOND,
THIRD,
FORTH,
} order_t;
Now, if I declare a variable such as:
order_t n;
compiler consider n as an integer (2 byte in a 16 bit environment).
If I use only 4 values in an enumeration, n can be a simple unsigned
char, i.e. sizeof(n)=1. Is it possible to use enumeration and to
specify byte-length of that enumeration?
I know that I can write:
typedef enum {
.... (as before)
} order_t;
unsigned char n;
....
n=FIRST;
....
But in that way I lose the link between variable and enumeration.