🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1846

Re: for (a=0; a<100; a++) ;

#1846
From: gnu
Date: Mon, 24 Oct 1988 17:20
15 lines
1201 bytes
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
Technical Details
Message-ID: <8810241720.AA22217@hop.toad.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!uunet!tut.cis.ohio-state.edu!toad.com!gnu
References: <1531@vaxnix.tandy.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!uunet!tut.cis.ohio-state.edu!toad.com!gnu
From: gnu@toad.com
Newsgroups: gnu.gcc.bug
Subject: Re: for (a=0; a<100; a++) ;
Message-ID: <8810241720.AA22217@hop.toad.com>
Date: 24 Oct 88 17:20:34 GMT
References: <1531@vaxnix.tandy.COM>
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 15