Re: Definition techniques using ESQL-C
Posted in 1992
I'd be the last to claim it was elegant, but the solution in the shell archive seems to work -- at least the code in xxx.ec gets compiled to xxx.o and the code in yyy.c gets compiled to yyy.o on Interactive 386/IX (3.2.2) and ESQL/C Version 5.00.UC2. The only thing to watch is that 'typedef struct Xyz { ... } Xyz;' wasn't accepted by the ESQL compiler (it said the name Xyz was already in use). Yours inelegantly (but effectively), Jonathan Leffler (johnl@obelix.informix.com) #include <disclaimer.h> >From: uunet!mt2.BELL-ATL.COM!dksl2vq (Rory Martin) >Subject: Re: Definition techniques using ESQL-C >To: informix-list@rmy.emory.edu >Date: Wed, 28 Oct 92 10:45:55 EST >X-Informix-List-Id: <list.1559> > >> I am a bit confused about how to do something that seems like it should >> be easy. I want to define a structure that can be used in both an >> ESQL-C source file and a standard c file. It seems that if I make >> a standard header file defining the structure using the standard >> c syntax ( struct foo { int bar; }; ), ESQL-C won't let me create a >> host variable of type struct foo. It only works if i use the following >> syntax ( $struct foo { int bar; }; ). This of course messes things >> up for standard c. > >Jon, >If anyone comes up with a reasonable way of doing this, let me know. : "@(#)shar.sh 1.9" #! /bin/sh # # This is a shell archive. # Remove everything above this line and run sh on the resulting file. # If this archive is complete, you will see this message at the end: # "All files extracted" # # Created: Wed Oct 28 21:05:03 GMT 1992 by jl at Informix Software Ltd. # Files archived in this archive: # xxx.ec # xxx.h # yyy.c # #-------------------- if [ -f xxx.ec -a "$1" != "-c" ] then echo shar: xxx.ec already exists else echo 'x - xxx.ec (219 characters)' sed -e 's/^X//' >xxx.ec <<'SHAR-EOF' XEXEC SQL INCLUDE "xxx.h"; XEXEC SQL INCLUDE sqlca; X Xswizzle() X{ X EXEC SQL BEGIN DECLARE SECTION; X Xyz xyz; X EXEC SQL END DECLARE SECTION; X X xyz.base = "worrizit"; X EXEC SQL DATABASE :xyz.base; X return(sqlca.sqlcode); X} SHAR-EOF chmod 644 xxx.ec if [ `wc -c <xxx.ec` -ne 219 ] then echo shar: xxx.ec unpacked with wrong size fi # end of overwriting check fi #-------------------- if [ -f xxx.h -a "$1" != "-c" ] then echo shar: xxx.h already exists else echo 'x - xxx.h (238 characters)' sed -e 's/^X//' >xxx.h <<'SHAR-EOF' X#ifndef ESQL_C X#define EXEC X#define SQL X#define BEGIN X#define END X#define DECLARE X#define SECTION extern int errno X#endif X XEXEC SQL BEGIN DECLARE SECTION; Xtypedef struct xyz X{ X int len; X char *base; X} Xyz; XEXEC SQL END DECLARE SECTION; SHAR-EOF chmod 644 xxx.h if [ `wc -c <xxx.h` -ne 238 ] then echo shar: xxx.h unpacked with wrong size fi # end of overwriting check fi #-------------------- if [ -f yyy.c -a "$1" != "-c" ] then echo shar: yyy.c already exists else echo 'x - yyy.c (72 characters)' sed -e 's/^X//' >yyy.c <<'SHAR-EOF' X#include "xxx.h" X Xjunk() X{ X Xyz xyz; X X xyz.len = 0; X return(xyz.len); X} SHAR-EOF chmod 644 yyy.c if [ `wc -c <yyy.c` -ne 72 ] then echo shar: yyy.c unpacked with wrong size fi # end of overwriting check fi echo All files extracted exit 0