BUG #13676: C typedef code generated by ecpg with wrong syntax - Mailing list pgsql-bugs

From glauciobb@hotmail.com
Subject BUG #13676: C typedef code generated by ecpg with wrong syntax
Date
Msg-id 20151013192757.2798.91073@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #13676: C typedef code generated by ecpg with wrong syntax  (John McKown <john.archie.mckown@gmail.com>)
Re: BUG #13676: C typedef code generated by ecpg with wrong syntax  (Michael Meskes <meskes@postgresql.org>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      13676
Logged by:          Gláucio Barros Barcelos
Email address:      glauciobb@hotmail.com
PostgreSQL version: 9.4.5
Operating system:   Oracle Linux Server release 6.7
Description:

Dear,

I trying to migrate my application developed using Pro*c to ECPG. But, when
I run the code below with "ecpg -c" command to generate c code, the syntax
for typedef generated appears to be wrong. Below is an sample code and the
steps to generate error return by C compiler due the wrong syntax for
typedef.

Step 1: Create a file with pgc extension with the code below:

#include <stdio.h>
EXEC SQL TYPE t_char_10  IS char[10];
int main()
{
    int status = 0;
    return status;
}

Step 2: pre compile the file with command: ecpg -c file.pgc. This command
will generate the c code below. Note that the  syntax for typedef is wrong.


/* Processed by ecpg (4.10.0) */
/* These include files are added by the preprocessor */
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
/* End of automatic include section */

#line 1 "example.pgc"
#include <stdio.h>

typedef  char [ 10 ] t_char_10 ;
#line 3 "example.pgc"

int main()
{
    int status = 0;
    return status;
}

Step 3: Try to compile the c code with command "cc -I/usr/pgsql-9.4/include
-c file.c".

file.pgc:3 error: expected indentifier or '(' before '[' token

best regards,
Gláucio

pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #13674: psql: \i from a script run through \e misparses SQL as \i arguments
Next
From: jkoceniak@mediamath.com
Date:
Subject: BUG #13677: CPU 100% for WITH RECURSIVE CTE Queries