newbie IAR MSP430 ptr array ?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
The following compiles fine in Visual Studio and is something that I do
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,

Re: newbie IAR MSP430 ptr array ?

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

seems like a bug or something to me  :(

Re: newbie IAR MSP430 ptr array ?

Quoted text here. Click to load it

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
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline