Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: why this pointer of C can't work in IAR 4.3?
PostPosted: Wed Aug 02, 2006 3:54 am 
Offline

Joined: Wed Aug 02, 2006 3:46 am
Posts: 1
The program followed can't work in IAR 4.3:
unsigned char ch[3];
unsigned short int len,i;
for(i=0;i<3;i++) ch[i]=i+1; //set the value of array

//the following word compiled ok, but can't execut.
//dest: get a short int by ch[0] and ch[1] .
//like: len=ch[0]<<8 | ch[1];
len=*(unsigned short int *)ch ;


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 14, 2006 11:38 am 
Offline

Joined: Mon Aug 14, 2006 11:16 am
Posts: 7
Hmm, thats interesting it doesnt work for the 4.40 either...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 14, 2006 12:33 pm 
Offline

Joined: Thu Feb 03, 2005 11:41 am
Posts: 87
Location: Erfurt/Germany
Hi,

try to align the character array to 32 bit then it should work (at least under gcc 3.x it worked).

But it really depends on the compiler, you cannot rely on it producing the correct code for that cast.

Reading the ARM docs will tell you why it doesn't work.

_________________
Senior IT Consultant
Germany


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron