Reply by Jack Klein September 9, 20052005-09-09
On 8 Sep 2005 13:25:53 -0700, "steve" <SteveKlett@gmail.com> wrote in
comp.arch.embedded:

> The following compiles fine in Visual Studio and is something that I do > often: > <code> > int a = 0; > int b = 0; > > int* ptrs[2]; > ptrs[0] = &a; > ptrs[1] = &b; > </code> > > This same code complains that "the size of an array must be greater > than zero" in IAR. > > Anyone know what I should do? Is there a switch somewhere that I need > to flip in the options? > > Is this "bad" code, seems fine and legal to me. > > Hope someone can help, > Steve
Is this code inside a function, or is it at file scope? If the code is at file scope, you cannot perform the assignments, you must initialize the variable in the declaration. Change those last three lines to this: int *ptrs[2] = { &a, &b }; ...and see what happens. -- Jack Klein Home: http://JK-Technology.Com FAQs for comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html comp.lang.c++ http://www.parashift.com/c++-faq-lite/ alt.comp.lang.learn.c-c++ http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
Reply by steve September 8, 20052005-09-08
confused!

It also complains with the same error about this code:
<code>
int tmp[10];
tmp[0] = 1;
</code>

seems like a bug or something to me  :(

Reply by steve September 8, 20052005-09-08
The following compiles fine in Visual Studio and is something that I do
often:
<code>
int a = 0;
int b = 0;

int* ptrs[2];
ptrs[0] = &a;
ptrs[1] = &b;
</code>

This same code complains that "the size of an array must be greater
than zero" in IAR.

Anyone know what I should do?  Is there a switch somewhere that I need
to flip in the options?

Is this "bad" code, seems fine and legal to me.

Hope someone can help,
Steve