Re: [HACKERS] psql vs. gcc - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] psql vs. gcc
Date
Msg-id 8312.945451441@sss.pgh.pa.us
Whole thread Raw
In response to psql vs. gcc  (Karel Zak - Zakkr <zakkr@zf.jcu.cz>)
Responses Re: [HACKERS] psql vs. gcc
List pgsql-hackers
Karel Zak - Zakkr <zakkr@zf.jcu.cz> writes:
>         strcpy(buf,
>            "SELECT pg_database.datname as \"Database\",\n"
>                    "       pg_user.usename as \"Owner\""
> #ifdef MULTIBYTE
>                    ",\n       pg_database.encoding as \"Encoding\""
> #endif
>                 );
> What is bad, my gcc or previous source code? (IMHO is Peter's code right and
> gcc is a little mazy).

After looking at my C reference, I believe gcc is following the ANSI C
spec and Peter's code is broken.  According to the book I'm looking at,
concatenation of adjacent string literals is specified to happen while
forming preprocessing tokens, which obviously must occur *before*
preprocessor directives are evaluated.  (#if throws away preprocessing
tokens, not raw characters...)  So when MULTIBYTE is defined, an
ANSI-compliant compiler will see a syntax error in the above.

> describe.c:324: warning: preprocessing directive not recognized within macro arg

Looks like there are a few other problems here too...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: [HACKERS] Re: Notation for nextval() (was Re: Several small patches)
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] LONG varsize - how to go on