Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

IAR AVR can not support multi dimention array ?

Status
Not open for further replies.

maziar

Full Member level 4
Joined
Jun 6, 2001
Messages
195
Helped
5
Reputation
10
Reaction score
1
Trophy points
1,298
Location
Islamic republic of Iran
Activity points
1,564
error[pe513]

IAR have problem with two dimension array ?


//////////// start of code

#include <iom16.h>

unsigned char VRAM [2][5];

void main(void)
{
unsigned char * p;
p = VRAM ;
PORTD = * p ;

}

////////////End of code

have generate :

Error[Pe513]: a value of type "unsigned char (*)[5]" cannot be assigned to an entity of type
"unsigned char *"

Errors: 1
Warnings: none



why ? Iar can not support multidimention array true ?

what to do ?
 

iar avr array

maziar,

VRAM is a two dimension array, so it would be wrong (from stricly ANSI) to assign it entirely to a pointer in such of way.

p = VRAM ;
would not assign to p the address of the element at [row0][col0] as for your intentions.

You should write for instance:

p = VRAM[0];. This would assign to p the address of the first element (row 0) at col 0.

Above wont give any error.
 

arrays in c assign avr

maziar said:
IAR have problem with two dimension array ?


//////////// start of code

#include <iom16.h>

unsigned char VRAM [2][5];

void main(void)
{
unsigned char * p;
p = VRAM ;
PORTD = * p ;

}

////////////End of code

have generate :

Error[Pe513]: a value of type "unsigned char (*)[5]" cannot be assigned to an entity of type
"unsigned char *"

Errors: 1
Warnings: none



why ? Iar can not support multidimention array true ?

what to do ?

or U can assign VRAM to pointer to pointer like this

unsigned char **p ;

p = VRAM ;



visioneer
 

iar c array multidimensional

It is not at all unusual the situation where some compiler is a bit more "permissive" then others. However it doesn't mean the result is correct even you don't receive back a compiler error. Often a check to the generated object code reveals most of traps.

Please read "Brian W. Kernighan & Dennis M. Ritchie" 2nd edition, chapter 5.7 MULTIDIMENSIONAL VECTORS.

About assigning a pointer to pointer I'm dubtly will work. The main problem here is when you need to pass VRAM [row][col] (to a pointer or as a function parameter) you need to specify [col] dimension except the very first dimension [row] that is free.
 

avr write array values

This is what PC-Lint tries to tell you:

PC-lint for C/C++ (NT) Ver. 8.00n, Copyright Gimpel Software 1985-2003
--- Module: E:\WINDOWS\Desktop\test.c

--- Module: E:\WINDOWS\Desktop\test.c
_
p = VRAM ;
E:\WINDOWS\Desktop\test.c 6 Error 64: Type mismatch (assignment) (unsigned char * = unsigned char (*)[5])

And here is what Error 64 means:

64 Type mismatch (Context) (TypeDiff)
-- There was a mismatch in types across an
assignment (or implied assignment, see Context). TypeDiff specifies the type difference.
See options -epn, -eps, -epu, -epp (Section 5.2 Error Inhibition Options) to suppress this mes-sage
when assigning some kinds of pointers.

have fun
 

array avr

Hi,

Try the line:
p=(unsigned char *)VRAM;

I think this will compile.


Sky.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top