Re: Having .ec and .c files see same structure definitions
Posted in 1997
>From: liedtke@itc.nrcs.usda.gov (Brian Liedtke) >Date: 11 Feb 1997 18:20:12 GMT >X-Informix-List-Id: <news.33765> > >If this is covered in the FAQ, could somebody point me to it? > >The question: > We have structure definitions that need to be seen by both .ec >and .c files. I have come up with a solution that seems to work >for me but others are having difficulty implementing it. Is there >a 'standard' soution out there that is a recommended? We are running >Informix 7.13. > >My solution for those interested: > >.ec files:------------------------------------------- >#define SQL_FILE >$include foo.h; >#undef SQL_FILE > >.c files:-------------------------------------------- > >#include <foo.h> > >foo.h:----------------------------------------------- > >#ifdef SQL_FILE >EXEC SQL BEGIN DECLARE SECTION; >#endif > >typedef struct { > . >} S1; > > . > >#ifdef SQL_FILE >EXEC SQL END DECLARE SECTION; >#endif > I use: -- .ec files -- EXEC SQL BEGIN DECLARE SECTION; $include "k.h"; EXEC SQL END DECLARE SECTION; function() { EXEC SQL BEGIN DECLARE SECTION; struct Sx a; EXEC SQL END DECLARE SECTION; } -- .c files -- #include "k.h" alternative() { S1 s; } -- .h files -- typedef struct Sx { int x; int y; } S1; Note that you can't do what I normally do with structures, which is: typedef struct S1 { ... } S1; If you try it, the ESQL/C compiler complains with: esqlc: "kk.ec", line 5: Error -33050: The type or subtype 'S1' has already been used. Yours,