dladdr() - how to use this function

Hello everybody,

I have tied to use dladdr() function to obtain a symbol name of the widget, but I don’t know what to put as the first parameter address. I tried something but the function still returned zero. Can you help me please?

Thanks meg

hi,

did you have allocate memory for the dl_info structure ? so can you give an example ?!

Hello,

Example: I have 10 PtButton widgets in my Phab project, and I have only one activate callback for all of them. I want to identify, which one invoked the callback, but I need symbol name (string), because I want to use part of it in next action.

OK, you are on the wrong track with dladdr.

It’s been a long time since programming photon, but doesn’t the widget instance contain the name in it? and even if it doesn’t I know you can attach user data to an instance.

That’s right. You can identify the widget either by the value of its pointer, or if you want you can store some identifying information in the user data field when you create it, and then read it in the callback. I prefer the latter. If you create the widget in Phab, and name each of the widgets, you can use their symbolic names to find them. There is also a way to search through a tree of widgets, but you would need something in the widget to help you identify it, eg. the label.

Thanks for tips, I will try to use it.
Cheers