From: | "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h |
Date: | 2016-02-06 18:10:08 |
Message-ID: | 20160206181008.GC8832@hjp.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On 2016-02-01 13:16:20 +0100, Michael Meskes wrote:
> > and ends on an ordinary line. I am not sure what the C standard says
> > about such cases, but I can certainly imagine that some tools might not
> > be very happy with that.
>
> We/I have to figure out what the standard says, because if it allows
> these comments, the lexer itself has to be fixed to work correctly
> instead of just fixing the header files.
The relevant translation phases are 3 and 4 according to the C standard
(section 5.1.1.2 in C11):
| 3. The source file is decomposed into preprocessing tokens7) and
| sequences of white-space characters (including comments). A source
| file shall not end in a partial preprocessing token or in a partial
| comment. Each comment is replaced by one space character. New-line
| characters are retained. Whether each nonempty sequence of
| white-space characters other than new-line is retained or replaced
| by one space character is implementation-defined.
|
| 4. Preprocessing directives are executed, macro invocations are
| expanded, and _Pragma unary operator expressions are executed. If a
| character sequence that matches the syntax of a universal character
| name is produced by token concatenation (6.10.3.3), the behavior is
| undefined. A #include preprocessing directive causes the named
| header or source file to be processed from phase 1 through phase 4,
| recursively. All preprocessing directives are then deleted.
Comments are replaced with whitespace in phase 3, preprocessing
directives are are only considered in phase 4. So code like
----------------------------------------------------------------------------
#ifndef _ECPGLIB_H /* source created by ecpg which defines these
* symbols */
----------------------------------------------------------------------------
is valid C and should be exactly equivalent to
----------------------------------------------------------------------------
#ifndef _ECPGLIB_H 

----------------------------------------------------------------------------
( denotes a newline character here)
hp
--
_ | Peter J. Holzer | I want to forget all about both belts and
|_|_) | | suspenders; instead, I want to buy pants
| | | hjp(at)hjp(dot)at | that actually fit.
__/ | http://www.hjp.at/ | -- http://noncombatant.org/
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-02-06 23:30:20 | Re: Re[2]: [BUGS] Segfault in MemoryContextAlloc |
Previous Message | Andres Freund | 2016-02-06 17:49:30 | Re: Re: BUG #13685: Archiving while idle every archive_timeout with wal_level hot_standby |