Nios - II memory alignment issue while accessing integer from non word align location
Error Msg : Not getting any error message but getting unexpected behavior
- Using Nios-II with eclipse. While accessing integer(32 bit) form non word align location getting incorrect value as described in below example.
- Tested with eclipse version 13 and 16, both are giving same result.
- Test case :
--------------------------------------------------------------------------------
char c[10] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
printf("int = 0x%08x", *(int*)(&c[2]));
--------------------------------------------------------------------------------
above code should print "int = 0x66554433" but getting "int = 0x44332211"
Hi Vasu,
Try by going to the project folders > right-click > properties> Nios II Application properties >
Debug Level = 2
Optimization Level =2
This gives the required output
Best Regards,
Anand Raj Shankar
(This message was posted on behalf of Intel Corporation)