Yes, I want the compiler to optimise it away, but I'd like it to do so without complaining about the "timeout" variable. The following code has similar problems:
void func(void) { return; { int timeout; timeout = 0xFFFF; while (timeout--); } } Mary-Ann Ken Jackson wrote: > I don't know the answer, though I offer an observation. > > Most compilers will optimize away the delay that you are > trying to implement. Therefore you should declare timeout this way: > > volatile int timeout; > > Also, when I do it that way, I don't get the warning. > > -Ken Jackson > > Mary-Ann Johnson writes: > > If I compile the following code (SDCC 2.7.0): > > > > ------------------------------------------------ > > void func(void) > > { > > int timeout; > > > > return; > > > > timeout = 0xFFFF; > > while (timeout--); > > } > > ------------------------------------------------ > > > > SDCC produces the following warnings: > > "src/test.c:8: warning 84: 'auto' variable 'timeout' may > > be used before initialization > > src/test.c:8: warning 84: 'auto' variable 'timeout' may be > > be used before initialization > > src/test.c:8: warning 84: 'auto' variable 'timeout' may be > > used before initialization" > > > > Any idea why? > > > > And before someone says "Don't call 'return' there!" - > > this scenario happens when a macro is set to "return" to > > eliminate the 2nd half of a function. > > > > Thanks, > > Mary-Ann ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user