Re: E/SQL host arrays with defined sizes
Posted in 1998
On Thu, 1 Oct 1998, Tim Friest wrote: > I would like to use defines for the sizes of some of the arrays in my > ESQL/C code... > > #define COLUMN_WIDTH 18 > > EXEC SQL BEGIN DECLARE; > char column[COLUMN_WIDTH+1]; > EXEC SQL END DECLARE; > > EXEC SQL SELECT column into :column FROM table > WHERE something=something; > > When something like the above is compiled, esqlc generates warnings like > > esqlc: "????.ec", line ###: Warning -33208: Runtime error is possible > because size of 'column' is unknown. > > but other places I use similar arrays I do not get warnings about > unknown size... It's a nuisance, but that's what it does. I have not managed to explain to the ESQL/C team that this is a problem, though I tried, very hard, to do so. It isn't likely to be fixed, so you're stuck with a one of a few methods of dealing with it: * Ignore these warnings * Compile with the -warn flag in release code (and suffer during development because you don't want to miss other non-spurious warnings). * Code around it with: char a_column[COLUMN_WIDTH+1]; EXEC SQL BEGIN DECLARE SECTION; char column = a_column; EXEC SQL END DECLARE SECTION; I tend to use the latter, but I also hack my esql script so that the -c option means that the C compiler (GCC) doesn't get given the libraries and doesn't witter about unused options and files. That is, there are other things which I work around in my way because I'm fed up with trying to get them fixed properly. Beware that the maximum length of column names will soon rise to 128 characters; owner names will jump to 32. > The reason I want to use the #define instead of the hard coded size is > because I have a column which changed width and I now have to go to the > half dozen places that it is hardcoded with the old size to fix it to the > new size. I would just assume fix it with a #define so I won't run > into this problem again. Yours, Jonathan Leffler (jleffler@informix.com) #include <witticism.h> Guardian of DBD::Informix v0.60 -- http://www.perl.com/CPAN Informix IDN for D4GL & Linux -- http://www.informix.com/idn