ECPG and typedef struct
ECPG and typedef struct
От:
Edmund Bacon <ebacon@onesystem.com>
Дата:
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
Re: ECPG and typedef struct
От:
Michael Meskes <meskes@postgresql.org>
Дата:
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!