From: Matthew Vanecek <mevanecek@yahoo.com>
To: Michael Meskes <meskes@postgresql.org>
Cc: Postgresql Interfaces List <pgsql-interfaces@postgresql.org>
Subject: Re: ECPG and C++ compilation
Date: 25 Feb 2003 14:44:45 -0600
Message-ID: <1046205884.12260.77.camel@reliant.home.pri> (raw)
In-Reply-To: <20030224152458.GA2980@feivel.fam-meskes.de>
References: <NDBBLJPIEGAHHANHMMBBEEOGCNAA.dpant@intracom.gr>
<1045926883.27169.76.camel@reliant.home.pri>
<20030224152458.GA2980@feivel.fam-meskes.de>
On Mon, 2003-02-24 at 09:24, Michael Meskes wrote:
> On Sat, Feb 22, 2003 at 09:14:43AM -0600, Matthew Vanecek wrote:
> > I don't think that will work. I can never get ecpg to recognize
> > typedefed structs, even when declaring the typedefed struct within a
> > DECLARE SECTION.
>
> Now that I do not understand. What exactly doesn't work? do you have a
> small example?
>
#include <stdio.h>
EXEC SQL BEGIN DECLARE SECTION;
struct s_somestruct {
int id;
char *field;
};
typedef struct s_somestruct SomeStruct;
EXEC SQL END DECLARE SECTION;
int main(int argc, char **argv)
{
printf("this is just to show parse errors from ecpg\n");
return 0;
}
yields:
me2v@reliant conn $ ecpg example.pgc
example.pgc:7: ERROR: parse error at or near ";"
If instead I use:
#include <stdio.h>
struct s_somestruct {
int id;
char *field;
};
EXEC SQL BEGIN DECLARE SECTION;
typedef struct s_somestruct SomeStruct;
EXEC SQL END DECLARE SECTION;
int main(int argc, char **argv)
{
printf("this is just to show parse errors from ecpg\n");
return 0;
}
I get:
me2v@reliant conn $ ecpg example.pgc
example.pgc:9: ERROR: parse error at or near "SomeStruct"
I get this error also if I use:
EXEC SQL BEGIN DECLARE SECTION;
struct s_somestruct {
int id;
char *field;
} a_struct;
typedef struct s_somestruct SomeStruct;
EXEC SQL END DECLARE SECTION;
Doing "typedef struct { /* stuff */ } AStruct;" appears to work with
ecpg from 7.3.2, but IIRC, it would not work in 7.2.3.
> > Probably doing the sizeof calculation within ecpg would be the proper
> > way to go, and using that value in the ECPGdo call instead of
> > sizeof(whatever). With respect to C++, anyhow. I'm sure the developers
>
> But that would mean you cannot precompile on one machine for usage on
> another. Right?
>
Is sizeof() a compile-time execution/calculation? If so, then it would
definitely not be portable, unless you implemented/used a generic types
library (such as glib, for example). Since it works in C, though, and
ECPG generates C, I'm by no means making a suggestion to follow this
path. ;)
--
Matthew Vanecek
perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
********************************************************************************
For 93 million miles, there is nothing between the sun and my shadow except me.
I'm always getting in the way of something...
Attachments:
signature.asc (application/pgp-signature, 231B) download
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: pgsql-interfaces@postgresql.org
Cc: mevanecek@yahoo.com, meskes@postgresql.org
Subject: Re: ECPG and C++ compilation
In-Reply-To: <1046205884.12260.77.camel@reliant.home.pri>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox