pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Raymond Fung <raymondf@valentia.com.hk>
To: pgsql-admin <pgsql-admin@postgresql.org>
Subject: ecpg problem : pre-processor translated hex constant to char
Date: Thu, 04 Jul 2002 05:00:44 +0800
Message-ID: <3D2365FC.3E353D4C@acm.org> (raw)

Dear all,

A simple testing program :

* * * * * * * * * * * * * *  begin  * * * * * * * * * * * * * * * *

#include <stdio.h>
#include <stdlib.h>

int main (void)
{
  unsigned int   v;

  v = 0x87654321L;

  return (0);
}

* * * * * * * * * * * * * *  end  * * * * * * * * * * * * * * * *

compile with ecpg using :

  ecpg -o mytest.c -I/usr/include/pgsql mytest.pgc

produces the output C program file as follow :

* * * * * * * * * * * * * *  begin  * * * * * * * * * * * * * * * *

/* Processed by ecpg (2.8.0) */
/* These three include files are added by the preprocessor */
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#line 1 "test.pgc"
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
  unsigned int   v;

  v = '0x87654321'L;

  return (0);
}

* * * * * * * * * * * * * * *  end  * * * * * * * * * * * * * * *

It has translated the 4 bytes constant (0x87654321) into a one byte
char constant (within the single quotes) during pre-processing. Seems
this happens only when the high bit of the constant is set (i.e. it
won't add the quotes if the constant is 0x12345678). 

Also, I noticed that the line number reported during the preprocessing 
error output is incorrect : it is '1' less than the actual line number 
in the source file. As shown, I am using version 2.8.0 of ecpg. Is my 
version being too old to be buggy ? Any suggestion to bypass the 
translation problem ?

Thanks,
Raymond Fung.





Message-ID: <3D2365FC.3E353D4C@acm.org>
Permalink:  ../3D2365FC.3E353D4C@acm.org/
Also on:    postgresql.org/message-id/3D2365FC.3E353D4C@acm.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: raymondf@valentia.com.hk
  Subject: Re: ecpg problem : pre-processor translated hex constant to char
  In-Reply-To: <3D2365FC.3E353D4C@acm.org>
  References: <3D2365FC.3E353D4C@acm.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox