If you are using Visual Studio, each file must end with a line consisting of just the enter key.
I have to say that I have never noticed that with visual studio. However it is part of the C and C++ standards that every line containing code must end with a newline, and I have come across a few compilers that check for this (Visual Studio not being one of them up to now), this causes a problem if for instance you don't put a newline after the closing brace of the last function in the file (something that is not visually obvious in most editors).
Another cause of you problem could be poorly positioned /closed comments. Although less likely in these days of chroma coded editors where commented out code is normally obvious if you accidentally managed to comment out a closing brace this would have the same effect as leaving it out.
It is of course possible to achieve the same effect with preprocessor directives (#if etc) instead of comments.