Thread: ECPG fails to handle hex constants

ECPG fails to handle hex constants

From
Thad Humphries
Date:
I stumbled across this bug yesterday.  My compiler (gcc 2.95.3 on RedHat
6.2) was telling me

    query.pgc:1383: character constant too long

so I compiled to query.c vs. query.o.  I found that

    if ( field->flags & 0x80000000 )
became
    if ( field->flags & '0x80000000' )

after passing thru ecpg, although it does not appear inside any EXEC SQL
clauses. (field->flags is an 's32' which is typedef'd from int.)

I worked around this problem by thus

/* Do this else ECPG makes 0x80000000 a char */
#define MASK_HI_BIT 0x80000000
...
    if ( field->flags & MASK_HI_BIT )

which leaves it all to the C preprocessor.  But why should I have to?
Is this really a bug in ecpg?
------------------------------------------------------------------------
Thad Humphries              "...no religious test shall ever be required
Web Development Manager      as a qualification to any office or public
Phone: 540/675-3015, x225    trust under the United States." -Article VI