Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

MSP430 Compiler issue with int array?

$
0
0

Champs,

So this actually came through my customer; but it's totally a tools issue that I can only agree with in that I reproduced it; but as to why is a mystery.  So the question, pretty much unaltered, goes like this:

Does not work:
 
static const uint8_t      arr_0[] = {0x00, 0x11};
static const uint8_t      arr_1[] = {0x22, 0x33};
 
static const uint8_t *    arr_arr[] = { arr_0, arr_1 };
 
voidhelper_func(void)
{
worker_func( arr_1 );           //works
worker_func( arr_arr[1]);    //does not work (erratic results, should behave the same as the line above)
}
 
Does work:
 
static const uint8      arr_0[] = {0x00, 0x11};
static const uint8      arr_1[] = {0x22, 0x33};
 
static const int        arr_arr[] = {(int)arr_0, (int)arr_1 };
 
voidhelper_func(void)
{
worker_func( arr_1 );                   //works
worker_func((uint8 *)arr_arr[1]);   //works (identical behavior to line above)
}
 

So it seems we have to explicitly cast the "array of arrays" as a uint8_t pointer on the function call; which shouldn't be required per standard C.  Any ideas why?


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>