repost: esql compile problems
Posted in 2000
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL
I can't find my original question on the archives so I'll try again esql 9.21.UC1 Solaris 2.7 Compile Sun WorkShop Compilers 5.0 98/12/15 C 5.0 When I try to compile the demo code I get the following e.g. esqlc: "timeout.ec", line 162: Error -33200: Invalid statement on symbol 'int4'. esqlc: "timeout.ec", line 336: Error -33200: Invalid statement on symbol 'mint'. Why aren't int4 and mint etc begin interpreted correctly. They only don't expand when used in the ESQL DECLARE statements i.e. for timeout.ec in demo code mint cnt = 0; #OK int4 ret = 0; #OK int4 sqlcode = 0; #OK int4 sqlerr_code, sqlstate_err(); #OK void disp_exception(), disp_error(), disp_warning(); EXEC SQL BEGIN DECLARE SECTION; char fld1_val[ CHARFLDSIZE + 1 ]; char fld2_val[ CHARFLDSIZE + 1 ]; int4 int_val; #Fails EXEC SQL END DECLARE SECTION; -- Paul Watson # WF Software # If it was easy Tel ++44 1436 674729 # Everybody could do it Fax ++44 1436 678693 # www.wfsoftware.com/informix #
> for timeout.ec in demo code > > mint cnt = 0; #OK > int4 ret = 0; #OK > int4 sqlcode = 0; #OK > int4 sqlerr_code, sqlstate_err(); #OK > void disp_exception(), disp_error(), disp_warning(); > > EXEC SQL BEGIN DECLARE SECTION; > char fld1_val[ CHARFLDSIZE + 1 ]; > char fld2_val[ CHARFLDSIZE + 1 ]; > int4 int_val; #Fails > EXEC SQL END DECLARE SECTION; In order to use a data type inside an exec sql declare section, it must first be defined inside a declare section. Where is int4 defined? If you defined it, try putting the definition inside of an exec sql declare section, like this: exec sql begin declare section; typedef ...; exec sql end declare section; or if it was defined in a header file, try using exec sql begin declare section; exec sql include <someheader.h>; exec sql end declare section; -- # unrm / ksh: unrm: not found # man cpio Sent via Deja.com http://www.deja.com/ Before you buy.
mars1972@my-deja.com wrote: > > for timeout.ec in demo code > > > > mint cnt = 0; #OK > > int4 ret = 0; #OK > > int4 sqlcode = 0; #OK > > int4 sqlerr_code, sqlstate_err(); #OK > > void disp_exception(), disp_error(), disp_warning(); > > > > EXEC SQL BEGIN DECLARE SECTION; > > char fld1_val[ CHARFLDSIZE + 1 ]; > > char fld2_val[ CHARFLDSIZE + 1 ]; > > int4 int_val; #Fails > > EXEC SQL END DECLARE SECTION; > > In order to use a data type inside an exec sql declare section, it must > first be defined inside a declare section. Where is int4 defined? If > you defined it, try putting the definition inside of an exec sql declare > section, like this: > exec sql begin declare section; > typedef ...; > exec sql end declare section; > > or if it was defined in a header file, try using > > exec sql begin declare section; > exec sql include <someheader.h>; > exec sql end declare section; Absolutely the right idea. You probably don't want the angle brackets around the someheader.h, but the semi-colon is necessary. The types int4 et al are likely to be defined in one of the two headers which are also automatically included by ESQL/C (the headers are sqlhdr.h and sqliapi.h in CSDK versions of ESQL/C). These headers drag in almost all the other ESQL/C headers between them. Now, often it is a problem to obtain control over the compilation before those headers are #include'd by the C compiler. In this case, though, the code is copied into the ESQL/C file by the ESQL/C pre- processor before the C compiler sees it. However, the C pre- processor will include those files again, and therefore you could still end up with problems due to repeated typedefs. C99 allows them when the types are identical, so maybe compilers will let this through in future. There's a chance I'm worrying unnecessarily -- it may work exactly as Mars1972 suggests. I have a feeling it will be more complex, though. And now I've confused everyone enough, I'll shut up. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.95 -- see http://www.perl.com/CPAN #include <disclaimer.h>