Know if const qualifier is used

后端 未结 4 1603
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 13:46

Is there any way in C to find if a variable has the const qualifier? Or if it\'s stored in the .rodata section?

For example, if I have this function:



        
4条回答
  •  醉梦人生
    2021-01-19 14:24

    Not in standard C, i.e. not portably.

    myString is just a char* in foo, all other information is lost. Whatever you feed into the function is automatically converted to char*.

    And C does not know about ".rodata".

    Depending on your platform you could check the address in myString (if you know your address ranges).

提交回复
热议问题