Reputation: 49251
I have a shared library with 2 methods (among others of course) that i want to port to linux:
GetProcessName() - Should get the executable name or path (either would do)
GetModuleName() - Should return the name of the module that's running the code (either dll or exe).
In a windows environment I use GetModuleFileName with a different variation for both methods.
I've seen plenty of solutions for getting the process name, but most of them seem kinda Hacky.
And I haven't found a solution for getting the module name.
Is there a similar function in linux ?
How can I implement them ?
Upvotes: 1
Views: 2282
Reputation: 179917
Since there's some confusion, here are the two steps to get the "module" data for the current function.
__builtin_return_address(0)
. Yet another method is to just take &foo
inside foo()
.dladdr
, passing the address of the current function.Upvotes: 3