warning: pointer of type ‘void *’ used in arithmetic

前端 未结 3 2234
南方客
南方客 2021-02-18 23:09

I am writing and reading registers from a memory map, like this:

//READ
return *((volatile uint32_t *) ( map + offset ));

//WRITE
*((volatile uint32_t *) ( map          


        
3条回答
  •  萌比男神i
    2021-02-18 23:33

    Type void is incomplete type. Its size is unknown. So the pointer arithmetic with pointers to void has no sense. You have to cast the pointer to type void to a pointer of some other type for example to pointer to char. Also take into account that you may not assign an object declared with qualifier volatile.

提交回复
热议问题