Re: [HACKERS] psql vs. gcc

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] psql vs. gcc
Дата
Msg-id 8312.945451441@sss.pgh.pa.us
обсуждение исходный текст
Ответ на psql vs. gcc  (Karel Zak - Zakkr <zakkr@zf.jcu.cz>)
Ответы Re: [HACKERS] psql vs. gcc  (Peter Eisentraut <peter_e@gmx.net>)
Список 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 по дате отправления:

Предыдущее
От: Thomas Lockhart
Дата:
Сообщение: Re: [HACKERS] Re: Notation for nextval() (was Re: Several small patches)
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] LONG varsize - how to go on