passing pointers to const to functions expecting non-const pointers?

Status
Not open for further replies.

mxxx

Well-known member
hi,

i'm stuck with a problem that's a bit above my head and i'd be much obliged for any hints as to how to sort it out.
i think my problem boils down to usage of arm_linear_interp_q15 (q15_t * pYData, q31_t x, uint32_t nValues ), which i'd like to make work on integer arrays declared const, to hopefully free up some RAM.

whatever i do though, i get "invalid conversion" errors, like so:

invalid conversion from 'const short int*' to 'q15_t* {aka short int*}' [-fpermissive]

for example, simplifying somewhat

whereas

Code:
short int wt1[] = {0, 65535, 64511, 60652, ... } 

[... ]

q15_t* waveform = wt1;
arm_linear_interp_q15(waveform, osc1.phase, SAMPLE_SIZE);

is okay, i can't really figure out how i'd pass it something like

Code:
 const short int wt1[] = {0, 65535, 64511, 60652, ... }

assuming that's possible.

what does seem to work is:

Code:
q15_t* waveform = const_cast<short int*>(wt1);

but i'm not sure whether that's how one would go about it? especially, as i don't want to spend a lot of time here

thanks!
 
Status
Not open for further replies.
Back
Top