Why I get; initializing 'char *' with an expression of type 'const char *' discards qualifiers?

后端 未结 6 1143
陌清茗
陌清茗 2021-01-05 05:37

I can\'t figure out why I get this warning from clang by myself:

function_prototype_const_modifier.c:13:8: warning: initializing \'char *\' with         


        
6条回答
  •  执笔经年
    2021-01-05 06:30

    You are pointing to the same area in memory, but not qualifying it as const as well, which the argument is.

    You then allow the function body to modify that part of memory which is labelled const.

提交回复
热议问题