Enumerate members of a structure?

前端 未结 6 923
渐次进展
渐次进展 2021-01-13 10:02

Is there a way to enumerate the members of a structure (struct | class) in C++ or C? I need to get the member name, type, and value. I\'ve used the following sample code b

6条回答
  •  深忆病人
    2021-01-13 10:17

    It feels like you are constructing some sort of debugger. I think this should be doable if you make sure you generate pdb files while building your executable.

    Not sure in what context you want to do this enumeration, but in your program you should be able to call functions from Microsofts dbghelp.dll to get type information from variables etc. (I'm assuming you are using windows, which might of course not be the case)

    Hope this helps to get you a little bit further.

    Cheers!

提交回复
热议问题