for loop as a macros
Please support our C++ advertiser: Programming Forums
![]() |
•
•
Posts: 206
Reputation:
Solved Threads: 29
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
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. Apart from anything else this useless macros must be
c++ Syntax (Toggle Plain Text)
#define FOR(x,n)for(typeof(x)x=0;x<(n);x++)
![]() |
Similar Threads
Other Threads in the C++ Forum
- Starting Python (Python)
- Excel macros with asp.net (ASP.NET)
- need help.. VBA in access and excel.. (Visual Basic 4 / 5 / 6)
- Tricky Questions (C)
- substitute of semicolon (C++)
- vc++ mfc-i can't make getline work with a string for file input (C++)
- can someone please explain??????? (C)
- Need help with recursion and arrays (C++)
- Sorting a selection (Visual Basic 4 / 5 / 6)
- Safe Array (C++)
Other Threads in the C++ Forum
- Previous Thread: Quick question
- Next Thread: Help with manually creating a BMP image
•
•
•
•
Views: 431 | Replies: 3 | Currently Viewing: 1 (0 members and 1 guests)






Linear Mode