gnu@toad.com (10/25/88)
If you want 'for (a=0; a<100; a++) ;' to generate a delay loop, declare 'volatile int a;'. Otherwise, ANSI C's "as if" rule lets the compiler generate any code it wants, as long as the effect is "as if" it had done things the way you said. There's no requirement that the compiler generate slow object code if you write slow source code (e.g. delay loops); the standard says nothing at all about time, just about ordering of events. If you want delay loops, I recommend defining a DELAY macro which takes an argument in nanoseconds. That way people can tweak the macro to generate at least that much delay in their environment, without having to change any of the calls to the macro. You'll also be documenting what your delay loop is really trying to accomplish (e.g. 'a 2ms delay is needed here'). John