c - Discarded 'const' qualifier at assignment -


i have following code -

int acb(const uint16 *msgptr)  {  uint16 *p = (msgptr + 1); printf("%d", *p);  } 

i following warning - discarded 'const' qualifier @ assignment line above printf. how resolve?

the argument acb pointer constant uint16, pointer you're creating not pointing constant. discards const qualifier. either remove const argument passed function or make p point const uint16.

why case? tell compiler guarantee won't change msgptr points to, create pointer can modify msgptr points *(p - 1) = ...;


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -