avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fwd: RE: [Fwd: RE: [avr-chat] BOOTLOADER on ATMega644]]


From: Blake Leverett
Subject: Re: [Fwd: RE: [Fwd: RE: [avr-chat] BOOTLOADER on ATMega644]]
Date: Tue, 23 Dec 2008 06:49:33 -0700
User-agent: KMail/1.9.9

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]