C++ Cross-Platform Problems
by Feihong Hsu


Contents:


Problem: warning: no newline at end of file
Solution: Open your file, go to the end of the last line, and press Enter.  Save and close the file.
Problem:
^M all over your source file
Solution:
Open your file using pine.  Press Control+o to save your file.  Press Control+x to close the file.
Problem:
name lookup of `i' changed for new ISO `for' scoping
Solution:
You must have something like the following:
for (int i=0; i < 7; i++) {
// for loop body
}

// You use i outside of the loop, e.g. i = 43;

The problem is that the scope of i in the above example is restricted to the body of the for loop in g++.   So if you want to use the variable i outside of the for loop, you will have to define it outside the for loop.  It would look something like this:
int i;
for (i=0; i < 7; i++) {
// for loop body
}

// You use i outside of the loop, e.g. i = 43;