Re: BUG #13676: C typedef code generated by ecpg with wrong syntax

Поиск
Список
Период
Сортировка
От John McKown
Тема Re: BUG #13676: C typedef code generated by ecpg with wrong syntax
Дата
Msg-id CAAJSdjjFdvWOKWSWHudYcqjHfHBqVr__HvA6zC6wd=WMpg7mgA@mail.gmail.com
обсуждение исходный текст
Ответ на BUG #13676: C typedef code generated by ecpg with wrong syntax  (glauciobb@hotmail.com)
Список pgsql-bugs
This is just me, but I'm wondering if the examples on page:
http://www.postgresql.org/docs/9.4/static/ecpg-sql-type.html are
misleading. The text on that page says "TYPE type_name IS ctype" and
defines ctype as "a C type specification". The example on that page, which
is similar to yours is:

EXEC SQL TYPE string IS char[11];

But I am fairly user that "char[11]" is _not_ a "C type specification". An
"array" is not a C type. A "char" is. As are things like: int, long int,
float, double, etc. I.e. you say "char data[10];" and not "char[10] data".
C doesn't have a "string" data type.

So I'm wondering if the ecpg processor is doing things correctly but the
examples are bad.

I not saying, I'm asking.

On Tue, Oct 13, 2015 at 2:27 PM, <glauciobb@hotmail.com> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      13676
> Logged by:          Gl=C3=A1ucio 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, wh=
en
> I run the code below with "ecpg -c" command to generate c code, the synta=
x
> for typedef generated appears to be wrong. Below is an sample code and th=
e
> 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 =3D 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 wron=
g.
>
>
> /* 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 =3D 0;
>         return status;
> }
>
> Step 3: Try to compile the c code with command "cc -I/usr/pgsql-9.4/inclu=
de
> -c file.c".
>
> file.pgc:3 error: expected indentifier or '(' before '[' token
>
> best regards,
> Gl=C3=A1ucio
>
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>



--=20

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones =3D 1 Megaphone

Maranatha! <><
John McKown

В списке pgsql-bugs по дате отправления:

Предыдущее
От: i.frolkov@postgrespro.ru
Дата:
Сообщение: BUG #13679: Planer chooses not optimal plan
Следующее
От: John Pruitt
Дата:
Сообщение: Re: BUG #13670: DST discrepancy between age() and subtraction for timestamptz arguments