![]() |
| ||
| for loop as a macros could somebody tell wats wrong with this #define FOR(x,n)for(typeof(x);x<n;x++) |
| ||
| Re: for loop as a macros Just don't use macros for loops. |
| ||
| Re: for loop as a macros 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. |
| ||
| Re: for loop as a macros Apart from anything else this useless macros must be #define FOR(x,n)for(typeof(x)x=0;x<(n);x++) |
| All times are GMT -4. The time now is 9:26 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC