newbie IAR MSP430 ptr array ?

Sep 08, 2005 2 Replies

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



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 :(

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

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required