This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: preprocessing directive with no new-line character
- From: Vincent Lefevre <vincent+gcc at vinc17 dot org>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: Dennis Clarke <dclarke at blastwave dot org>, gcc-help at gcc dot gnu dot org
- Date: Mon, 7 Aug 2017 02:47:53 +0200
- Subject: Re: preprocessing directive with no new-line character
- Authentication-results: sourceware.org; auth=none
- References: <20170717131958.GA23989@zira.vinc17.org> <CA+7wUswGQyztN70aiHRp1RARa4-erV6cYN2Ys=gD0st6x-Z4PA@mail.gmail.com> <20170717141517.GA29555@zira.vinc17.org> <8cb25e84-cac2-4185-81e1-bbc3f14d653c@gmail.com> <cc81ab28-6779-146d-c604-8345aec4e511@blastwave.org> <e160e634-f61c-12e6-7660-ef61c92e07bc@gmail.com>
On 2017-07-18 17:43:50 -0600, Martin Sebor wrote:
> Yes, C requires every non-empty source file to have at least
> one line. The C11 standard says in 5.1.1.2 Translation phases,
> p2:
>
> 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.
I've reported a bug for the missing warning:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81745
It was closed because
https://gcc.gnu.org/ml/gcc-patches/2007-04/msg00504.html
"It's really not undefined at all. gcc would be still be standard
conformant if we defined all input to end with a newline, whether or
not the actual physical Unix input file did so."
However, this is not documented in the GCC manual and the preprocessor
behaves differently whether the input file ends with a backslash or
ends with a backslash-newline:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81745#c7
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)