3 registered members (NewbieZorro, TipmyPip, 1 invisible),
19,045
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
for loop with blank comparison statement
#358235
02/09/11 23:37
02/09/11 23:37
|
Joined: Feb 2011
Posts: 135
Myrkling
OP
Member
|
OP
Member
Joined: Feb 2011
Posts: 135
|
for (i = 0; ; i++) { ... }
This compiles fine in 8.10.1, but causes random crashes during runtime ("Crash in SYS"). As this relation is not that obvious, it should be mentioned in the manual (or fixed) I think.
|
|
|
Re: for loop with blank comparison statement
[Re: Myrkling]
#358278
02/10/11 10:10
02/10/11 10:10
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
Serious User
|
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
for (int i = 0; i < 100; i++) {...}
It's also not possible to declare a variable in a for loop. It would be great if this would be possible too.
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: for loop with blank comparison statement
[Re: Pappenheimer]
#358285
02/10/11 11:48
02/10/11 11:48
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Well, its useful in the case when you want an iterator in an endless loop. Its the same as:
int i;
i = 0;
while(1)
{
// foo
i++;
}
(imo for(i=0; ; i++) is less ugly) The C Standard allows you to have any or none of the components set in a for loop, so this would be also possible: for(;;) {} or just for(;;i++) { }. And Dark_Samurai: Declaring variables in an for loop is C99 and imo Lite-C only aimes compatibility to a subset of C89.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: for loop with blank comparison statement
[Re: Pappenheimer]
#358292
02/10/11 13:58
02/10/11 13:58
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
You can have an endless loop, and in GUI application you actually should have one. The problem with Acknex and endless loops is that Acknex never gets the control back and can't draw a new frame or respond to Windows events. Thus Windows thinks your application has stopped responding and marks it as irresponsive. But in the background of Acknex there is at leas one while() loop, mainly the one which fires the drawing and the responding to windows events. A typical application life cycle looks like this:
while(notTerminated)
{
dispatchEvents();
updateUI();
// Do some other stuff
}
(This is btw the perfect place to do non-blocking socket stuff to have asynchronous networking in the main thread)
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: for loop with blank comparison statement
[Re: jcl]
#358441
02/11/11 11:19
02/11/11 11:19
|
Joined: Jan 2011
Posts: 122 GUILIN , CHINA
tzw
Member
|
Member
Joined: Jan 2011
Posts: 122
GUILIN , CHINA
|
but in c99 it work i think
Full of my eyes are class struggles.....
|
|
|
|