Im trying to compile a simple kernel with gcc. I am using the djgpp port on Windows ME. I am getting a really weird error and I was wondering if anybody knows what this is.
Well, it's actually a warning.. it doesn't affect the output of your compiled code.
Some C compilers require a newline character at the end of your source code. GCC doesn't but it gives a friendly warning nevertheless. Just put an empty line at the end of all your .c and .h files.
Just try putting a enter at the end of the code...still a problem? Ignore it. Nothing will happen ingoring it. GCC sometimes gets confused about new lines for me to.
Ah, yes, the good old "no newline at end of file" error.
I remember one time I was writing a program with either lex or yacc (I don't remember which), and I was getting tons and tons of errors with no apparent cause whatsoever. The one error that wasn't reported was the single problem that fixed them all: no newline at the end of the file. Don't ask me why it makes a difference, but for some programs it does. Fortunately, gcc is not one of them.
Thanks for the help guys. Adding a newline helped. I am confused on something though.
When I type in the lines to compile in a .batch file and run it, I get no warnings at all, not even the newline warning. But when I run it from the command-line in DOS, I get that warning.
Why is this so? Is there a flaw in gcc or does this happen to all compilers. I am new to compilers and I was wondering if anybody could explain to me why this happens.
most warnings are good warnings. I compile NAGI with these warnings:
-Wall -Winline -Wshadow -Wstrict-prototypes
It may be annoying to fix all the warnings that come up.. But it picks up sooo many mistakes that you might not catch the first time you compile the code.
Annoyed that gcc gives a warning because you don't have a newline at the end? What if somebody else picks up your code and tries to compile it on another compiler that requires it and gives an error?
I haven't used VC++ but is it true that on the highest warnng level, the compiler picks up warnings in *microsoft*'s library headers??
Tom wrote:
I'd like to re-program my GCC to get rid of that warning...
That may not be too wise; the warnings were put into the compiler for a reason. This specific warning is meant to help detect truncated source files, which, while rare in general, can sometimes be an issue when compiling source downloaded over unreliable network lines.
Most gcc warnings can be disabled, in any case. If you check the docs, you'll probably find the parropriate switch to take care of it.