I thought #1
uint8_t* start_ptr, end_ptr;
and #2
uint8_t* start_ptr;
uint8_t* end_ptr;
are generally the same. It seems to me they are not. Could somebody specify what the first one does other than the second?
What happened:
if(strncmp(mseq,mseq_a,8) == 0){
start_ptr = MY_UART_RingBuffer_getReadPointer();
start_found = 1;
}
if(strncmp(mseq+3,mseq_z,5) == 0){
end_ptr = MY_UART_RingBuffer_getReadPointer();
if (start_found == 1){
if(!MY_UART_RingBuffer_getOverlap()){
end_ptr = end_ptr - 6;
}
else{
start_found = 0;
continue;
}
ptrdiff_t length = end_ptr - start_ptr;
start_found = 0;
}
}
On using #1 the compiler will give me this for the length calculation:
../Core/Src/main.c:143:32: error: invalid operands to binary - (have 'int' and 'uint8_t * {aka unsigned char *}')
ptrdiff_t length = end_ptr - start_ptr;
On using #2 everything works out fine.
I am somehow confused here. I see the solution but I don't really get the issue.
Thanks a lot ;-)