Re: Sharing structs between ESQL and 'C'
Posted in 1992
}From: uunet!gauss.rutgers.edu!manmetha (Rajesh Malhotra) }Subject: Sharing structs between ESQL and 'C' }Date: 18 Nov 92 19:57:51 GMT }X-Informix-List-Id: <news.2157> } }Fellow Informixers, } } Is there a way to share structure definitions between 'C' and }the ESQL definitions? }i.e. Say I have an ESQL definition of the type } } $typedef struct { } char var1; } int var2 } } SQLstruct; } }and I also need a 'C' struct } } typedef struct { } char var1; } int var2; } } Cstruct; } }Must I have two definitions. Is there a workaround that would help me get }by with a single declaration? This almost comes into the FAQ category, and I've had two previous goes at answering it. One of them is elegant and simple; t'other (the more recent, I regret to say), was horrible and kludgy. So, I enclose the whole elegant solution, and the header of the grotesque solution. I can't think why I couldn't remember in October what I'd said in September... Yours, Jonathan Leffler (johnl@obelix.informix.com) #include <disclaimer.h> Elegant solution posted in September: }Date: Thu Sep 17 12:12:40 1992 }From: johnl (Jonathan Leffler) }Subject: Re: Declaring Host Variables with STRUCT } }>From: uunet!mprgate.mpr.ca!sandie (Bert Sandie) }>Subject: Declaring Host Variables with STRUCT }>Date: 16 Sep 92 19:38:52 GMT }>X-Informix-List-Id: <news.1818> }> }> ... }> }>The reason I want to use the first method is that I have existing }>structures which have many embedded STRUCT and I do not want to }>have to redeclare these in ESQL/C for a second time. } }Ah, Easy, I thought. No, better check it. Checked it, and it didn't }work, mainly because I was using a 4.00 ESQL compiler in which temp is }a reserved word. When tested on a machine with 5.00, it worked OK. } }This works under 5.00 (and probably 4.10, but I haven't proved that!). } }File temp.h: }struct temp }{ } char t_l[15]; } char t_f[15]; }}; } }File temp.ec: }EXEC SQL BEGIN DECLARE SECTION }$include "temp.h"; }struct temp temp1; }EXEC SQL END DECLARE SECTION Comment: it would be neater to use this: EXEC SQL INCLUDE "temp.h"; Header from grotesque solution posted in October: }Date: Wed, 28 Oct 92 21:21:46 GMT }From: uunet!obelix.informix.com!johnl (Jonathan Leffler) }Subject: Re: Definition techniques using ESQL-C }X-Informix-List-Id: <list.1560> } }I'd be the last to claim it was elegant, but the solution in the }shell archive seems to work