no newline warning

How can I stop the compiler from giving a warning when there is no new line? I write code using Visual C++ and compile under a POSIX/Unix emulator(cygwin) and VC++ automatically removes any extra lines at the end of a file when it saves and it is kind of annoying.

Thanks for any help.
I've yet to get MS's VC++Express to install on my PC (stupid nonsense about .NET 3 that I can't quite figure out yet.)

But I find it amazing that any code editor actually strips all blank lines at the EOF. Are you sure there isn't some editor option that will turn that off?

Either way, you can easily filter with a simple program:
1
2
3
4
5
6
7
8
9
#include <fstream>
using namespace std;

int main( int argc, char** argv )
  {
  for (int n = 1; n < argc; n++)
    ofstream( argv[ n ], ios::app ) << endl;
  return 0;
  }

Use it from the (*nix) command-line as (example):

a.out *.cpp *.h


Hope this helps.

[edit] For Windows/DOS users out there, remember that the DOS command shell doesn't expand wildcards, so you would have to specify every name individually or just use a for loop:

for %f in (*.y *.z) do @a.exe %f
Last edited on
Topic archived. No new replies allowed.