Firstly, there is no space between the closing bracket at the end of FOR(x,n) and preceding the rest. That's a stylistic concern, but badly hurts readability.
Second, and more significantly, typeof() is not a standard function or operator in C++. It is an extension specific to g++ (GNU c++) in which typeof(x) expands to be type of x and will trigger a compiler error with every compiler that does not support that extension. Within a for loop (assuming you're using g++), if x is an int, then FOR(x,n) would expand to for (int; x < n; x++) which is invalid code.
"#define FOR(x,n)for(typeof(x)x=0;x<(n);x++)" won't even work. In order for typeof() to function, x has to already exist, and if x already exists the compiler will complain that you're redeclaring x. EG:
will expand to "for(int x=0; x<(10);x++", but you already declared x... The closest you might want is "FOR(n) for(int x=0; x<(n); x++)" but I fail to see much point. If you're going to macro a for loop, do so because you're controlling the entire loop for a specific set. Such as:
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.