pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ECPG and typedef struct
2+ messages / 2 participants
[nested] [flat]

* ECPG and typedef struct
@ 2004-01-19 18:31  Edmund Bacon <ebacon@onesystem.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Edmund Bacon @ 2004-01-19 18:31 UTC (permalink / raw)
  To: pgsql-interfaces

Is it still necessary to define SQL TYPEs twice?

eg

typedef struct foo { ... } foo_t;

EXEC SQL TYPE foo_t IS struct foo { ... };

Is there some less maintenance-error-prone way to accomplish this?  I
know about the -c option to ecpg, but this doesn't help if I need to
access the defined type from a .c file.

Ideally the C level typedef would be in a .h file somewhere and either
#include-ed or EXEC SQL INCLUDE-ed into .c or .pgc file

Thanks

-- 
Edmund Bacon <ebacon@onesystem.com>




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: ECPG and typedef struct
@ 2004-01-27 17:53  Michael Meskes <meskes@postgresql.org>
  parent: Edmund Bacon <ebacon@onesystem.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Meskes @ 2004-01-27 17:53 UTC (permalink / raw)
  To: Edmund Bacon <ebacon@onesystem.com>; +Cc: pgsql-interfaces

On Mon, Jan 19, 2004 at 11:31:36AM -0700, Edmund Bacon wrote:
> Is it still necessary to define SQL TYPEs twice?

It depends, but teh way you ask, yes.

> Is there some less maintenance-error-prone way to accomplish this?  I
> know about the -c option to ecpg, but this doesn't help if I need to
> access the defined type from a .c file.

Why? Can't you just put it into a header file that is processed by ecpg
to create a C header and use "-c" for this? Okay, this does include the
ecpg headers also, but if that's the problem we could add an option
easily.

How about an option "parsing header file"?

> Ideally the C level typedef would be in a .h file somewhere and either
> #include-ed or EXEC SQL INCLUDE-ed into .c or .pgc file

Would it be okay to do this:

Write a *.pgh file, that is SQL-INCLUDE-ed in embedded sql files. For C
you'd call "ecpg -h" on that file, making ecpg produce a .h file, that
can be included by your C code.

Hmm, I think I'm going to implement that immediately. :-)

Michael

-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2004-01-27 17:53 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-01-19 18:31 ECPG and typedef struct Edmund Bacon <ebacon@onesystem.com>
2004-01-27 17:53 ` Michael Meskes <meskes@postgresql.org>

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