| | |
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 based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion count database delete deploy desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






