tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] C99 for loop with variable declarations


From: Claudio Bley
Subject: [Tinycc-devel] C99 for loop with variable declarations
Date: Mon, 21 Jun 2010 16:42:37 +0200

Hi.

I just pushed a new change to the mob branch
(http://repo.or.cz/w/tinycc.git/commit/433ecdfc9d1402ecf03e710de481e2063ad6de90)
 adding support for C99 for loops a few hours ago.

A simple test program works as expected:
    
--- snip --
#include <stdio.h>
    
int main(int argc, char *argv[]) {
   int k = 5, i = -1, j = -2;
   for (int i = 0, j = 9;
      i < k;
      ++i, j += i)
   {
      printf("%d / %d\n", i, j);
   }
   printf("%d / %d\n", i, j);
   return 0;
}
--- snip --
    
Output:
   
0 / 9
1 / 10
2 / 12
3 / 15
4 / 19
-1 / -2
    
Beware: I merely made some educated guesses as to what some functions
are doing and just copy'n'pasted a few lines of code. Works for me,
YMMV.

Any comments, critics or improvements are welcome.

Cheers,

- Claudio



reply via email to

[Prev in Thread] Current Thread [Next in Thread]