The expression is probably not 'too complex for the compiler' but too complex for the programmer.
Your intention was probably not if (pgm_read_byte((PGM_P)(TESTIMAGE + (IMAGE_SIZE * projnum) + SIGNATURE) != 0)) but if (pgm_read_byte((PGM_P)(TESTIMAGE + (IMAGE_SIZE * projnum) + SIGNATURE)) != 0) My experience is that we are almost never as clever as we think we are. /Janne On Thu, 05 Feb 2009 09:45:36 +0100 Robert von Knobloch <b...@engelking.de> wrote: > Weddington, Eric wrote: > > > > > > > >> -----Original Message----- > >> From: > >> avr-gcc-list-bounces+eweddington=cso.atmel....@nongnu.org > >> [mailto:avr-gcc-list-bounces+eweddington=cso.atmel....@nongnu. > >> org] On Behalf Of Robert von Knobloch > >> Sent: Monday, February 02, 2009 8:49 AM > >> To: avr-gcc-list@nongnu.org > >> Subject: [avr-gcc-list] Accessing function and strings in > >> flash in theATMega 644 > >> > >> > > > > > >> if (pgm_read_byte((PGM_P)(TESTIMAGE + (IMAGE_SIZE * projnum) + > >> SIGNATURE) != 0)) > >> > > <snip> > > > >> Can anyone tell me a: why this does not work and/or what I am > >> assuming that is wrong? > >> > > > > Remember that pgm_read_byte() is a *macro* and not a function. And > > to top it off, that macro generates inline assembly. You have a > > very complex expression in the parameter portion of the macro. > > > > I strongly suggest that you take out the expression and assign it > > to another variable, and just use that variable in place of the > > pgem_read_byte() paramater. As a precaution, take out the call to > > pgm_read_byte() from the if statement. > > > > Like so: > > > > address = (TESTIMAGE + (IMAGE_SIZE * projnum) + SIGNATURE); > > byte = pgm_read_byte(address); > > if (byte != 0) > > { > > // code > > } > > > > See if that helps. > > > > Eric Weddington > > > > > > > Yes Eric, that produces quite sensible code that actually works. > Thank you for the insight. Just two small questions: > > 1. Why is this 'too complex for the compiler' ? > 2. How can I know when the compiler's complexity limit has been > reached? > > (OK, I don't really expect you to be able to answer. It's just that I > expect a compiler to relieve me of worrying about complex statements. > The only complexity is really (IMAGE_SIZE * projnum), all the rest are > just adding constants - in my simple view). > > Many thanks, > > Robert > > > _______________________________________________ > AVR-GCC-list mailing list > AVR-GCC-list@nongnu.org > http://lists.nongnu.org/mailman/listinfo/avr-gcc-list -- Unna dig ett bättre liv, dumpa Windows! _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list