Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #10135

Re: Is a blank at the end of a C file a better style than a newline at the end of the file or is it better to place none?

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Is a blank at the end of a C file a better style than a newline at the end of the file or is it better to place none?
Date 2011-09-11 10:55 -0700
Organization None to speak of
Message-ID <lnk49farr6.fsf@nuthaus.mib.org> (permalink)
References <j4dtve$kj3$1@speranza.aioe.org> <j4eb8i$uoo$1@dont-email.me> <lnobysc1p9.fsf@nuthaus.mib.org> <j4fo1r$ngf$1@dont-email.me>

Show all headers | View raw


Eric Sosman <esosman@ieee-dot-org.invalid> writes:
> On 9/10/2011 3:10 AM, Keith Thompson wrote:
>> Eric Sosman<esosman@ieee-dot-org.invalid>  writes:
>>> On 9/9/2011 4:46 PM, Jimmy wrote:
>>>> Hello everyone!
>>>>
>>>> As the subject says. The reason for my question is that emacs always
>>>> suggest me to put a newline at the end of  the C file if I forget to do
>>>> it. Why?
>>>
>>>       Because it's required.  5.1.1.2p2:
>>>
>>> 	A source file that is not empty shall end in a new-line
>>> 	character, which shall not be immediately preceded by a
>>> 	backslash character [...]
>>
>> Yes, but that's not a constraint, which means that a compiler isn't
>> required to complain about it.  [...]
>
>     Surely emacs is within its rights to recommend that a source
> file be well-formed, even if the compiler is not required to diagnose
> deviations?
>
>     Heck, emacs goes so far as to suggest line indentations, which
> the compiler doesn't need at all.

Of course.  vim (at least by default) doesn't even allow you to create a
file without a trailing newline.

But emacs isn't asking about the newline because C needs it; it does
that for all text files.

I was merely quibbling about the word "required".

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Is a blank at the end of a C file a better style than a newline at the end of the file or is it better to place none? Jimmy <nospam@trash.invalid> - 2011-09-09 20:46 +0000
  Re: Is a blank at the end of a C file a better style than a newline at the end of the file or is it better to place none? Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-09 20:32 -0400
    Re: Is a blank at the end of a C file a better style than a newline at the end of the file or is it better to place none? Keith Thompson <kst-u@mib.org> - 2011-09-10 00:10 -0700
      Re: Is a blank at the end of a C file a better style than a newline at the end of the file or is it better to place none? Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-10 09:16 -0400
        Re: Is a blank at the end of a C file a better style than a newline at the end of the file or is it better to place none? Roberto Waltman <usenet@rwaltman.com> - 2011-09-10 11:36 -0400
          Re: Is a blank at the end of a C file a better style than a newline at the end of the file or is it better to place none? ec429 <ec429@cam.ac.uk> - 2011-09-10 16:55 +0100
          Re: Is a blank at the end of a C file a better style than a newline at the end of the file or is it better to place none? gazelle@shell.xmission.com (Kenny McCormack) - 2011-09-10 17:42 +0000
            Re: Is a blank at the end of a C file a better style than a newline at   none? Nomen Nescio <nobody@dizum.com> - 2011-09-10 23:57 +0200
              Re: Is a blank at the end of a C file a better style than a newline at   none? Patrick Scheible <kkt@zipcon.net> - 2011-09-10 20:46 -0700
                Re: Is a blank at the end of a C file a better style than a newline at   none? gazelle@shell.xmission.com (Kenny McCormack) - 2011-09-11 12:45 +0000
                Re: Is a blank at the end of a C file a better style than a newline at  none? Jimmy <nospam@trash.invalid> - 2011-09-11 19:21 +0000
                Re: Is a blank at the end of a C file a better style than a newline at none? Peter Nilsson <airia@acay.com.au> - 2011-09-20 17:17 -0700
                Re: Is a blank at the end of a C file a better style than a newline at  none? Kelsey Bjarnason <kbjarnason@gmail.com> - 2011-09-20 15:35 -0700
        Re: Is a blank at the end of a C file a better style than a newline at the end of the file or is it better to place none? Keith Thompson <kst-u@mib.org> - 2011-09-11 10:55 -0700

csiph-web