| | |
for loop as a macros
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2008
Posts: 206
Reputation:
Solved Threads: 31
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
- Starting Python (Python)
- Safe Array (C++)
- 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)
Other Threads in the C++ Forum
- Previous Thread: Quick question
- Next Thread: Help with manually creating a BMP image
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






