public inbox for [email protected]  
help / color / mirror / Atom feed
From: Ashutosh Sharma <[email protected]>
To: [email protected]
Subject: ecpg: issue related to preprocessor directives
Date: Fri, 31 Jul 2020 10:46:00 +0530
Message-ID: <CAE9k0P=dQk9X0cU2tN49S7a9tv733-e1pVdpB1P-pWJ5PdTktg@mail.gmail.com> (raw)

Hi All,

When the following ecpg program having preprocessor directives is compiled,
the output produced is not correct.

/* test program */
exec sql define itype 1;

int main(void)
{
    exec sql begin declare section;
    exec sql ifdef itype;
        int var1;
    exec sql elif ntype;
        numeric var1;
    exec sql else;
        float var1;
    exec sql endif;
    exec sql end declare section;
}

Here is the output produced by th ecpg pre-compiler when above program is
compiled:

int main(void)
{
/* exec sql begin declare section */

#line 8 "2.pgc"
 int var1 ;

#line 12 "2.pgc"
 float var1 ;

/* exec sql end declare section */
#line 14 "2.pgc"
}

As seen from above output, both exec sql ifdef and exec sql else block got
compiled which is wrong. If the above output is further compiled using gcc
compiler, the compilation would fail.

--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com


view thread (7+ messages)  latest in thread

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: ecpg: issue related to preprocessor directives
  In-Reply-To: <CAE9k0P=dQk9X0cU2tN49S7a9tv733-e1pVdpB1P-pWJ5PdTktg@mail.gmail.com>

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

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