Programmatic way to get variable name in C?

前端 未结 10 1814
广开言路
广开言路 2020-11-29 23:08

I am developing a tool to dump data from variables. I need to dump the variable name, and also the values.

My solution: Store variable name as a string, and print th

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 23:40

    In C, variable names exist during the compile step (and the link step, if the variable is global), but are not available at runtime. You must choose a solution that involves a literal string indicating the variable name.

提交回复
热议问题