Whats this Error mean?

Discussion in 'C++' started by Weasel, Nov 9, 2005.

  1. Weasel

    Weasel Guest

    This occured right after i tryed to compile the file


    hello.cpp:9:2: warning: no newline at end of file
    Weasel, Nov 9, 2005
    #1
    1. Advertising

  2. Weasel wrote:
    > This occured right after i tryed to compile the file
    >
    >
    > hello.cpp:9:2: warning: no newline at end of file


    Uhhmmm... it means what it says. The last character of the file is
    supposed to be a newline. Open the file. Go to the end. Hit <Enter>
    (or whatever the equivalent is on your keyboard). Save the file.
    Recompile. The warning should be gone.

    By the way - it was a warning, not an error. It didn't stop you from
    compiling the file, but making the above change will make the compiler
    stop giving you that warning. But you should consult your compiler
    documentation for more info.

    Best regards,

    Tom
    Thomas Tutone, Nov 9, 2005
    #2
    1. Advertising

  3. Weasel

    Weasel Guest

    o ok ty ty ty sorry im just learning c++ :(
    Weasel, Nov 9, 2005
    #3
  4. Weasel

    Default User Guest

    Weasel wrote:

    > o ok ty ty ty sorry im just learning c++ :(


    That's nice. Are you still learning how to use Google? I know I've
    mentioned the quote thing to you before? Why are you not using it?


    Brian

    --
    Please quote enough of the previous message for context. To do so from
    Google, click "show options" and use the Reply shown in the expanded
    header.
    Default User, Nov 9, 2005
    #4
  5. Weasel

    Greg Comeau Guest

    In article <>,
    Weasel <> wrote:
    >This occured right after i tryed to compile the file
    >hello.cpp:9:2: warning: no newline at end of file


    Comeau, in strict mode, gives:

    error: last line of file ends without a newline

    In other modes it might just be a warning.
    In C mode, the diagnostic can be removed.


    As both these compilers are saying, source files should
    end with a newline. The C++ Standard says in 2.1p2:
    "If a source file that is not empty does not end in a new-line
    character, or ends in a new-line character immediately
    preceded by a backslash character, the behavior is undefined."
    C99 5.1.1.2p2 reads:
    "A source file that is not empty shall end in a new-line character,
    which shall not be immediately preceded by a backslash character
    before any such splicing takes place."

    This normally occurs as a result of a text editor that does not
    put out a trailing NL in a text file. It may also indicate that
    somehow the rest of a file got tossed, though that would also
    normally give some other errors if it got cut off so abruptly.
    --
    Greg Comeau / Celebrating 20 years of Comeauity!
    Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
    World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
    Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
    Greg Comeau, Nov 11, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neo

    whats this error??

    Neo, Jan 31, 2005, in forum: VHDL
    Replies:
    4
    Views:
    486
  2. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    Whats the error:- System.NullReferenceException:

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 31, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    4,577
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Nov 1, 2004
  3. Replies:
    1
    Views:
    355
    Victor Bazarov
    Aug 17, 2006
  4. chanson
    Replies:
    2
    Views:
    604
    jeppe
    Oct 9, 2009
  5. C Barrington-Leigh
    Replies:
    1
    Views:
    1,178
    Tim Leslie
    Sep 10, 2010
Loading...

Share This Page