-4

I was reading a c++ code and i came across this problem and i don't know what it mean:

uint8 (*const flag_search)[SEARCH_RANGE]=
(uint8 (*)[SEARCH_RANGE])&_flag_search[MAX_MOTION][MAX_MOTION];

can someone explain it for me ?

songyuanyao
  • 169,198
  • 16
  • 310
  • 405
pooria
  • 343
  • 2
  • 14

1 Answers1

4
uint8 (*const flag_search)[SEARCH_RANGE]

flag_search is a const pointer pointing to an array, which contains SEARCH_RANGE elements with type uint8.

(uint8 (*)[SEARCH_RANGE])&_flag_search[MAX_MOTION][MAX_MOTION]

&_flag_search[MAX_MOTION][MAX_MOTION] will take the address of _flag_search[MAX_MOTION][MAX_MOTION], and cast it to uint8 (*)[SEARCH_RANGE], which is a non-const pointer pointing to an array, which contains SEARCH_RANGE elements with type uint8.

songyuanyao
  • 169,198
  • 16
  • 310
  • 405