Unix Technical Forum

Re: dynamic fixchar array ?

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 | | | | | ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 07:18 AM
Andrew Hardy
 
Posts: n/a
Default Re: dynamic fixchar array ?



----- 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 07:18 AM
Richard Harnden
 
Posts: n/a
Default Re: dynamic fixchar array ?

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:16 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com