newbie IAR MSP430 ptr array ?

The following compiles fine in Visual Studio and is something that I do often:

int a = 0; int b = 0;

int* ptrs[2]; ptrs[0] = &a; ptrs[1] = &b;

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

Reply to
steve
Loading thread data ...

confused!

It also complains with the same error about this code:

int tmp[10]; tmp[0] = 1;

seems like a bug or something to me :(

Reply to
steve

On 8 Sep 2005 13:25:53 -0700, "steve" wrote in comp.arch.embedded:

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 to
Jack Klein

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.