Hi,

If I compile current source, gcc (2.95.2) return interesting error for
pgsql/describe.c.

gcc command line:

make[1]: Leaving directory /home/PG_DEVEL/pgsql.change/src/interfaces/libpq'
gcc -I../../interfaces/libpq -I../../include -I../../backend -O2 -Wall
-Wmissing-prototypes -DMULTIBYTE=LATIN2 -c -o describe.o describe.c


The gcc return error for next lines:

------
strcpy(buf,
"SELECT pg_database.datname as \"Database\",\n"
" pg_user.usename as \"Owner\""
#ifdef MULTIBYTE
",\n pg_database.encoding as \"Encoding\""
#endif
);
-------

If I instead strcpy() write sprintf(buf, ..) all is right.

What is bad, my gcc or previous source code? (IMHO is Peter's code right and
gcc is a little mazy).

Full error dump:

make -C ../../interfaces/libpq libpq.a
make[1]: Entering directory `/home/PG_DEVEL/pgsql.change/src/interfaces/libpq'
make[1]: `libpq.a' is up to date.
make[1]: Leaving directory `/home/PG_DEVEL/pgsql.change/src/interfaces/libpq'
gcc -I../../interfaces/libpq -I../../include -I../../backend -O2 -Wall -Wmissing-prototypes -DMULTIBYTE=LATIN2 -c -o describe.o describe.c
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c:324: warning: preprocessing directive not recognized within macro arg
describe.c: In function `listAllDbs':
describe.c:321: undefined or invalid # directive
describe.c:323: undefined or invalid # directive
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `#'
describe.c:324: parse error before `:'
make: *** [describe.o] Error 1


----------------------------------------------------------------------
Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/

Docs: http://docs.linux.cz (big docs archive)
Kim Project: http://home.zf.jcu.cz/~zakkr/kim/ (process manager)
FTP: ftp://ftp2.zf.jcu.cz/users/zakkr/ (C/ncurses/PgSQL)
-----------------------------------------------------------------------

Search Discussions

  • Thomas Lockhart at Dec 17, 1999 at 2:40 pm

    If I compile current source, gcc (2.95.2) return interesting error for
    pgsql/describe.c.
    The gcc return error for next lines:
    strcpy(buf,
    "SELECT pg_database.datname as \"Database\",\n"
    " pg_user.usename as \"Owner\""
    #ifdef MULTIBYTE
    ",\n pg_database.encoding as \"Encoding\""
    #endif
    );
    I'm sure we would accept a patch that changed this into a

    strcpy()
    #ifdef MULTIBYTE
    strcat()
    #endif

    sequence rather than this monolithic line.

    - Thomas

    --
    Thomas Lockhart lockhart@alumni.caltech.edu
    South Pasadena, California
  • Bruce Momjian at Dec 17, 1999 at 5:45 pm
    I accidentally rejected the proper fix for this yesterday because there
    was no description about what it was supposed to fix. Let me see if I
    can get it now.

    If I compile current source, gcc (2.95.2) return interesting error for
    pgsql/describe.c.
    The gcc return error for next lines:
    strcpy(buf,
    "SELECT pg_database.datname as \"Database\",\n"
    " pg_user.usename as \"Owner\""
    #ifdef MULTIBYTE
    ",\n pg_database.encoding as \"Encoding\""
    #endif
    );
    I'm sure we would accept a patch that changed this into a

    strcpy()
    #ifdef MULTIBYTE
    strcat()
    #endif

    sequence rather than this monolithic line.

    - Thomas

    --
    Thomas Lockhart lockhart@alumni.caltech.edu
    South Pasadena, California

    ************

    --
    Bruce Momjian | http://www.op.net/~candle
    maillist@candle.pha.pa.us | (610) 853-3000
    + If your life is a hard drive, | 830 Blythe Avenue
    + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
  • Tom Lane at Dec 17, 1999 at 5:25 pm

    Karel Zak - Zakkr 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
  • Peter Eisentraut at Dec 18, 1999 at 1:01 pm

    On 1999-12-17, Tom Lane mentioned:

    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.
    I usually compile all code with both gcc 2.8.1 and egcs 2.91.66 and make
    it -Wall -W proof. So I must consider that an omission in those compilers.
    Thanks for pointing it out.
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    Looks like there are a few other problems here too...
    The problem sounds more like strcpy is a macro now. Great. More macros.
    Just what I need. :)

    --
    Peter Eisentraut Sernanders väg 10:115
    peter_e@gmx.net 75262 Uppsala
    http://yi.org/peter-e/ Sweden
  • Bruce Momjian at Dec 17, 1999 at 6:00 pm
    OK, I have applied a patch to use strcat in the case of MULTIBYTE to add
    the needed extra line.

    Hi,

    If I compile current source, gcc (2.95.2) return interesting error for
    pgsql/describe.c.

    gcc command line:

    make[1]: Leaving directory /home/PG_DEVEL/pgsql.change/src/interfaces/libpq'
    gcc -I../../interfaces/libpq -I../../include -I../../backend -O2 -Wall
    -Wmissing-prototypes -DMULTIBYTE=LATIN2 -c -o describe.o describe.c


    The gcc return error for next lines:

    ------
    strcpy(buf,
    "SELECT pg_database.datname as \"Database\",\n"
    " pg_user.usename as \"Owner\""
    #ifdef MULTIBYTE
    ",\n pg_database.encoding as \"Encoding\""
    #endif
    );
    -------

    If I instead strcpy() write sprintf(buf, ..) all is right.

    What is bad, my gcc or previous source code? (IMHO is Peter's code right and
    gcc is a little mazy).

    Full error dump:

    make -C ../../interfaces/libpq libpq.a
    make[1]: Entering directory `/home/PG_DEVEL/pgsql.change/src/interfaces/libpq'
    make[1]: `libpq.a' is up to date.
    make[1]: Leaving directory `/home/PG_DEVEL/pgsql.change/src/interfaces/libpq'
    gcc -I../../interfaces/libpq -I../../include -I../../backend -O2 -Wall -Wmissing-prototypes -DMULTIBYTE=LATIN2 -c -o describe.o describe.c
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c:324: warning: preprocessing directive not recognized within macro arg
    describe.c: In function `listAllDbs':
    describe.c:321: undefined or invalid # directive
    describe.c:323: undefined or invalid # directive
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `#'
    describe.c:324: parse error before `:'
    make: *** [describe.o] Error 1


    ----------------------------------------------------------------------
    Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/

    Docs: http://docs.linux.cz (big docs archive)
    Kim Project: http://home.zf.jcu.cz/~zakkr/kim/ (process manager)
    FTP: ftp://ftp2.zf.jcu.cz/users/zakkr/ (C/ncurses/PgSQL)
    -----------------------------------------------------------------------


    ************

    --
    Bruce Momjian | http://www.op.net/~candle
    maillist@candle.pha.pa.us | (610) 853-3000
    + If your life is a hard drive, | 830 Blythe Avenue
    + Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedDec 17, '99 at 2:25p
activeDec 18, '99 at 1:01p
posts6
users5
websitepostgresql.org...
irc#postgresql

People

Translate

site design / logo © 2021 Grokbase