Re: [Dev-C++] No Newline At End of File
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: Vale G. <val...@at...> - 2005-01-30 17:52:51
|
> Here is an example with a program I have written. It is a one-file program, and it's relatively small: #include <stdio.h> #include <stdlib.h> <<< Is that line 2? . [snip] . exit(1); } <<< Probably line 70. > No matter how many times I hit the enter key at the end of this file, I keep getting this message: > 2 C:\Dev-Cpp\Templates\states.c:70 [Warning] no newline at end of file > How can a error that is supposed to occur at the end of the file occur in line 2 anyway? Strictly speaking, it's a warning. An error will prevent it from compiling but it compiles and runs. Some errors and warnings within functions are reported with the line number of the end of the function or the beginning of the function. The compiler sometimes cannot determine where the actual problem lies. Perhaps the problem actually lies on line 2 (and in stdlib.h) as indicated. Perhaps the compiler is confused by other warnings which this program produces. Turning on all warnings with "-W -Wall -Wunused -pedantic" compiler options and I get: C:/WINDOWS/Desktop/states.c: In function `main': C:/WINDOWS/Desktop/states.c:12: warning: implicit declaration of function `strcmp' C:/WINDOWS/Desktop/states.c:16: warning: implicit declaration of function `toupper' C:/WINDOWS/Desktop/states.c:10: warning: unused variable `st' C:/WINDOWS/Desktop/states.c:10: warning: unused variable `string' C:/WINDOWS/Desktop/states.c: In function `findstate': C:/WINDOWS/Desktop/states.c:31: warning: implicit declaration of function `strcpy' C:/WINDOWS/Desktop/states.c:31: warning: pointer targets in passing arg 1 of `strcpy' differ in signedness C:/WINDOWS/Desktop/states.c:32: warning: implicit declaration of function `strcat' C:/WINDOWS/Desktop/states.c:32: warning: pointer targets in passing arg 1 of `strcat' differ in signedness C:/WINDOWS/Desktop/states.c:33: warning: pointer targets in passing arg 1 of `strcat' differ in signedness C:/WINDOWS/Desktop/states.c:34: warning: pointer targets in passing arg 1 of `strcat' differ in signedness C:/WINDOWS/Desktop/states.c:35: warning: pointer targets in passing arg 1 of `strcat' differ in signedness C:/WINDOWS/Desktop/states.c:36: warning: pointer targets in passing arg 1 of `strcat' differ in signedness If you fix those warnings you might also correct the missing newline warning. Also, in Tools > Editor Options > General, make sure that "Keep Trailing Spaces" is unchecked. You have eight lines with trailing spaces. They probably aren't causing any problems but there's no use in cluttering up your code. Chuck |