Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VkbAE-0005Z3-RI for pgsql-bugs@arkaria.postgresql.org; Sun, 24 Nov 2013 14:59:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VkbAE-0003xP-AZ for pgsql-bugs@arkaria.postgresql.org; Sun, 24 Nov 2013 14:59:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VkbAC-0003w0-UT for pgsql-bugs@postgresql.org; Sun, 24 Nov 2013 14:59:57 +0000 Received: from [87.118.86.135] (helo=mail.cybertec.at) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VkbA5-0007cI-Df; Sun, 24 Nov 2013 14:59:56 +0000 Received: from localhost.localdomain (unknown [87.242.12.103]) by mail.cybertec.at (Postfix) with ESMTPSA id 57A703900394; Sun, 24 Nov 2013 14:59:40 +0000 (UTC) Message-ID: <5292145C.5000508@cybertec.at> Date: Sun, 24 Nov 2013 15:59:40 +0100 From: Boszormenyi Zoltan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Michael Meskes , alexsav23@gmail.com CC: pgsql-bugs@postgresql.org Subject: Re: BUG #8608: ECPG: sizeof() in EXEC SQL DECLARE SECTION References: <20131124115517.GA1658@feivel.credativ.lan> In-Reply-To: <20131124115517.GA1658@feivel.credativ.lan> Content-Type: multipart/alternative; boundary="------------050907040102020200090700" X-Host-Lookup-Failed: Reverse DNS lookup failed for 87.118.86.135 (deferred) X-Pg-Spam-Score: -1.1 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------050907040102020200090700 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit 2013-11-24 12:55 keltezéssel, Michael Meskes írta: > On Tue, Nov 19, 2013 at 10:39:48PM +0000, alexsav23@gmail.com wrote: >> d:\>"c:\Program Files\PostgreSQL\9.3\bin\ecpg.exe"-o 1.c 1.pgc >> 1.pgc: 4: ERROR: syntax error at or near "(" >> error deleting output file "1.c" > And another patch to try. Please send me feedback. I think it's needlessly narrows the scope of the problem. Consider this code: #include #define hide_size_of_var sizeof int main(void) { int a[hide_size_of_var(int)]; int i; for (i = 0; i < hide_size_of_var(int); i++) { a[i] = i*3; printf("i: %d a[i]: %d\n", i, a[i]); } return 0; } It compiles just fine in a C compiler and runs from 0 to 3 as expected. GCC 4.8.2 doesn't say anything about it with -Wall. I think you should pass everything through as is inside the '[' and ']' and let the C compiler fail if the code is not valid. Best regards, Zoltán Böszörményi > > Michael > > -- ---------------------------------- Zoltán Böszörményi Cybertec Schönig & Schönig GmbH Gröhrmühlgasse 26 A-2700 Wiener Neustadt, Austria Web: http://www.postgresql-support.de http://www.postgresql.at/ --------------050907040102020200090700 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
2013-11-24 12:55 keltezéssel, Michael Meskes írta:
On Tue, Nov 19, 2013 at 10:39:48PM +0000, alexsav23@gmail.com wrote:
d:\>"c:\Program Files\PostgreSQL\9.3\bin\ecpg.exe"-o 1.c 1.pgc
1.pgc: 4: ERROR: syntax error at or near  "("
error deleting output file "1.c" 
And another patch to try. Please send me feedback.

I think it's needlessly narrows the scope of the problem.
Consider this code:

#include <stdio.h>

#define hide_size_of_var sizeof

int main(void) {
    int a[hide_size_of_var(int)];
    int i;

    for (i = 0; i < hide_size_of_var(int); i++) {
        a[i] = i*3;
        printf("i: %d a[i]: %d\n", i, a[i]);
    }

    return 0;
}

It compiles just fine in a C compiler and runs from 0 to 3 as expected.
GCC 4.8.2 doesn't say anything about it with -Wall.

I think you should pass everything through as is inside the '[' and ']' and
let the C compiler fail if the code is not valid.

Best regards,
Zoltán Böszörményi


Michael



    


-- 
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
     http://www.postgresql.at/
--------------050907040102020200090700--