On Monday 22 December 2008, Bob Paddock wrote:
> Do Zero Length Arrays work in AVR GCC?
> I have never seen them used nor documented as such,
> but have never tried to use them.
I have used them recently, for a situation where we needed to have different
variables used for different builds. For example:
#define BIG 1
char data_array[1000*BIG]; // Zero if BIG==0
void somefunc(void)
{
if (BIG)
{
data_array[0] = 1;
}
}
This way, the program will compile if BIG == 0, but no space for the array is
allocated, and the if() statement inside somefunc will be optimized out.
I did it this way to prevent a lot of #if BIG statements, since I find that
code with a lot of #if's to be confusing.
Does anybody see a problem with doing this?
Blake
_______________________________________________
AVR-chat mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-chat