Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k1NP0-0002no-Ax for pgsql-interfaces@arkaria.postgresql.org; Fri, 31 Jul 2020 05:16:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k1NOz-0005xP-9o for pgsql-interfaces@arkaria.postgresql.org; Fri, 31 Jul 2020 05:16:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k1NOz-0005xI-0v for pgsql-interfaces@lists.postgresql.org; Fri, 31 Jul 2020 05:16:17 +0000 Received: from mail-yb1-xb31.google.com ([2607:f8b0:4864:20::b31]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k1NOw-0003Rn-Cx for pgsql-interfaces@postgresql.org; Fri, 31 Jul 2020 05:16:16 +0000 Received: by mail-yb1-xb31.google.com with SMTP id q16so13453528ybk.6 for ; Thu, 30 Jul 2020 22:16:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=BGin1n+Vr4eGXHrd0PnM857efZPitTh3cMhcQtgTkOc=; b=t86Riii2bGURI3jpS4Kx04/Xmmu6nbLGcxhdsfDG/bQUn2QZAlXVZe9LTwijprdYF8 sqMcDo/l4ye2NUXZFLcUcsdtPUDpVw2NIFCnwspA7NBUpC9OEpQflu2cOdlDsRsI3j9n Ak9eHndV+/4MkV/6fPTVP+30WzCms+I0EpPLkEoLpwmomuEMKPEAqVDmqL631aV2yk0r 97IvP9qNBbqNv5SvsOVvwPE/Tvw3rcX8dW1A6Q0QPkv9/4rk/jcAoXkP2DS5Im18kZuE UCEsZciw13i/TWlv5y5CZ6VbYe5iUSDWmzFJhrRFGLD0LmhYWlSmi8YkpcGDxQemOFjN wZng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=BGin1n+Vr4eGXHrd0PnM857efZPitTh3cMhcQtgTkOc=; b=EDjaP0uK6nClsrcVx0BdLlvToztBYzEliKUlLXE93T2/i3pezDdfNQVLvsBGoO3+lm nDNpH4IomrS2Fc+sD7ooKHWN2TqXouVLEyvff9OI63qfz1vEYfX4ShAVcLlzYjiRVPY6 NQ8KqLWB+D1VvMRUia6UlEczYRv7MuXfXiZKRU01L3j2kpfKNzVsFLVIX3Fiu8DNApWf 3WLBR3WP3nmEbBVuwiLEi6E+CQMRhe3BYJjN6G3hguIF4jm/SI519HQMq95GMoNISnMq MWvpEW8BS7tr71r7+blF7WagjnHGm+0SVccBfvVzImVyb+ma6Zeb02OZqrI7FinjDU8Y +4zQ== X-Gm-Message-State: AOAM533uGsj2+pANCdX/Xzv7ybMPBz0WW94Gxkj+k8ekcNT8aBdMnE8Y giZ+POKEUlmjeMTYuh9hFz9r3YASk+P/oRm8/y86gytESOU= X-Google-Smtp-Source: ABdhPJx/eYdJL5mudxk+mU4Gnz9XH5fJ22bJ7F/61kAKBS0udBEcxPhu9GGoBI2DSb/9hQyou0dcIZzYfn9foofQ6iM= X-Received: by 2002:a25:d1d5:: with SMTP id i204mr3667208ybg.146.1596172571844; Thu, 30 Jul 2020 22:16:11 -0700 (PDT) MIME-Version: 1.0 From: Ashutosh Sharma Date: Fri, 31 Jul 2020 10:46:00 +0530 Message-ID: Subject: ecpg: issue related to preprocessor directives To: pgsql-interfaces@postgresql.org Content-Type: multipart/alternative; boundary="0000000000002527f005abb5e3ba" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --0000000000002527f005abb5e3ba Content-Type: text/plain; charset="UTF-8" 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 --0000000000002527f005abb5e3ba Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi All,

When the following ecpg program having prep= rocessor directives is compiled, the output produced is not correct.
/* test program */
exec sql define itype 1;

int main(void)
{<= br>=C2=A0 =C2=A0 exec sql begin declare section;
=C2=A0 =C2=A0 exec sql = ifdef itype;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 int var1;
=C2=A0 =C2=A0 exec= sql elif ntype;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 numeric var1;
=C2=A0 =C2= =A0 exec sql else;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 float var1;
=C2=A0 =C2= =A0 exec sql endif;
=C2=A0 =C2=A0 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 sectio= n */

#line 8 "2.pgc"
=C2=A0int var1 ;

#line 12 &= quot;2.pgc"
=C2=A0float var1 ;

/* exec sql end declare secti= on */
#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=C2=A0compiled using gcc compiler, the=C2=A0com= pilation would fail.

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