tags:

views:

64

answers:

2

Fujitsu microcontroller used is 32bit. Hence enum storage is also 32bit. But in my project actually enum elements do not exceed more than 256. Is there any compiler options to size down the storage for enums?

A: 

C programming language is being used

This should not be in an answer. You should edit your question instead.
Joachim Sauer
A: 

You could use a bit field to be able to store 256 unique values in 8 words (256 bits / 32 bit words = 8), but then the compiler will no longer be able to enforce that only a single bit is set at a time. But, you could easily write a wrapper function to clear out all the previous bits before setting one. It would probably end up kind of messy, but that's what tends to happen when you start using these kinds of tricks at this level to save memory.

Mark Rushakoff