Complier output

This is a discussion on Complier output within the C Programming forums, part of the General Programming Boards category; Anyone know why gcc( maybe all compilers but i've only got this one ) warns, "warning: no new line at ...

  1. #1
    zsaniK Kinasz's Avatar
    Join Date
    Jan 2003
    Posts
    222

    Complier output

    Anyone know why gcc( maybe all compilers but i've only got this one ) warns, "warning: no new line at end of file"?

    If i dont correct the warning my progs still work ok.
    "Assumptions are the mother of all **** ups!"

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,854
    Because the format of text files demands a newline at the end of each line. It is possible that some utilities would ignore the last line.

    > If i dont correct the warning my progs still work ok.
    Probably, but is it really so difficult to just edit the file and put a newline in the proper place?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    zsaniK Kinasz's Avatar
    Join Date
    Jan 2003
    Posts
    222
    No its not difficult, I do it anyway because that warning is just plain annoying. But i was curious as to the reason. Thanks for the explaination.
    "Assumptions are the mother of all **** ups!"

  4. #4
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187
    Although I didn't insert new line at the end of source code, I have never got this warning. I don't know that.
    Is that an issue copying from DOS with ``^M'' as a line terminator?
    slackware 10.0; kernel 2.6.7
    gcc 3.4.0; glibc 2.3.2; vim editor
    migrating to freebsd 5.4

  5. #5
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006

    Re: Complier output

    Originally posted by Kinasz
    Anyone know why gcc( maybe all compilers but i've only got this one ) warns, "warning: no new line at end of file"?
    Because that is standard?
    5.1.1.2 Translation phases
    2. [...]A source file that is not empty shall end in a new-line character, [...]
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 03:08 PM
  2. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 03:29 PM
  3. Replies: 4
    Last Post: 11-30-2005, 04:44 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 06:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 05:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21