This is a discussion on Re: dynamic fixchar array ? within the Informix forums, part of the Database Server Software category; --> ----- Forwarded by Andrew Hardy/MAIN/MC1 on 21/07/2004 15:30 ----- |---------+----------------------------> | | Andrew Hardy | | | | | ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| ----- Forwarded by Andrew Hardy/MAIN/MC1 on 21/07/2004 15:30 ----- |---------+----------------------------> | | Andrew Hardy | | | | | | 21/07/2004 15:29 | | | | |---------+----------------------------> >--------------------------------------------------------------------------------------------------------------------------------------------------| | | | To: richard.harnden@lineone.net | | cc: | | Subject: Re: dynamic fixchar array ?(Document link: Andrew Hardy) | >--------------------------------------------------------------------------------------------------------------------------------------------------| Don't know if it helps, but... Compiles and works fine with the array size as a literal. Change the array size to a variable and no other changes and I get: "density_view.ec", line 259: non-constant initializer: op "NAME" "density_view.ec", line 291: cannot recover from previous errors line 259 being the start of a while loop about half way down the function following the first EXEC SQL DECLARE and EXEC SQL OPEN not the place I would have expected it to discover the error. I presume VAL means variable length array. Is C99 a version of 'C'? Are you saying you think VLAs are not in pre C99 and I'm probably running a version of the esql C compiler earlier than C99? Thanks. Andrew H. |---------+-----------------------------> | | Richard Harnden | | | <richard.harnden@l| | | ineone.net> | | | Sent by: | | | owner-informix-lis| | | t@iiug.org | | | | | | | | | 21/07/2004 11:58 | | | Please respond to | | | richard.harnden | | | | |---------+-----------------------------> >--------------------------------------------------------------------------------------------------------------------------------------------------| | | | To: informix-list@iiug.org | | cc: | | Subject: Re: dynamic fixchar array ? | >--------------------------------------------------------------------------------------------------------------------------------------------------| Andrew Hardy wrote: > I want to read from a number of different posible versions of a table where > field1 may be nchar(x) where x nay vary over versions of the database. > This situation already exists. I want the code below to select > successfully based on db version. Based on db version the size of field1 > in the_table will be set, but I am having difficulty compiling a > dynamically sized ESQL fixchar array. And the error message was? > fixchar data[the_size]; VLAs are C99, maybe that's the problem. -- rh sending to informix-list |
| ||||
| Andrew Hardy wrote: > Don't know if it helps, but... > > Compiles and works fine with the array size as a literal. This is probably your best bet. Might be worth trying with char, rather than fixchar. > > Change the array size to a variable and no other changes and I get: > > "density_view.ec", line 259: non-constant initializer: op "NAME" That's a C error: $cat foo.c int foo(void); int foo_value = foo(); $gcc foo.c foo.c:2: initializer element is not constant But it would be okay if 'int foo_value = foo();' was inside a function, just not at file-scope. I'm not sure why you would get that error at the start of a while loop. Can't you post the relevant bits of the actual code? It's difficult to second guess. > "density_view.ec", line 291: cannot recover from previous errors > > line 259 being the start of a while loop about half way down the function > following the first > > EXEC SQL DECLARE > and > EXEC SQL OPEN > > not the place I would have expected it to discover the error. > > I presume VAL means variable length array. Is C99 a version of 'C'? s/VAL/VLA/g Yes and yes. The previous, and more common, standard was C89. If your compiler doesn't whinge, then you're probably okay. > > Are you saying you think VLAs are not in pre C99 and I'm probably running a > version of the esql C compiler earlier than C99? No, they weren't. As a vendor specific extension, maybe. C99 adds VLAs and // comments, pretty much. The esql version shouldn't really matter, it's a pre-processor. -- rh |
| Thread Tools | |
| Display Modes | |
|
|